I have this map:
%{
"$include" => %{
"hospitals" => %{
"$include" => %{"rooms" => %{"beds" => %{}}},
"$order" => %{"id" => "$asc"}
},
"doctors" => %{
"$order" => %{"id" => "$desc"}
}
}
}
There is any number of $include
statements nested inside $include.
so it should be dynamic. The output should be.
%{
"$include" => %{
"hospitals" => %{
"$include" => %{"rooms" => %{"beds" => %{"binding" => "last"}, "binding" => "last"}},
"$order" => %{"id" => "$asc"},
"binding" => "first"
},
"doctors" => %{
"$order" => %{"id" => "$desc"},
"binding" => "first"
}
}
}
All the outer maps should include binding => "first"
and all nested include should contain "binding "=> "last"
.
Any help will be much appreciated.
Thanks