Reputation: 207
I have a structure
class Node {
List<string> ChildrenIds;
...
}
That I currently store and lookup in RavenDB but Include for results only lets me include down one level in the potentially many leveled tree. Is there any way to tell it to lookup recursively all of these Nodes referenced from the top level?
I know indexes can be used recursively but I wasn't clear on how best to use that to load the correct documents, is it possible to somehow do an Include on an index property?
Upvotes: 0
Views: 197
Reputation: 22956
Yes, you use the JS support in the query, like so:
declare function recursiveInclude(n){
for(var i = 0; i<n.ChildrenIds.length; i++)
recursiveInclude(load(n.ChildrenIds[i]));
return n;
}
from Node as n
select recursiveInclude(n)
Upvotes: 1