Mongoid recursively find embedded document

Viewed 956

What is the best way to find a recursively embedded document?

I have the following setup:

Group embeds many posts. Post recursively embeds many posts.

Given an id of a post embedded object, is there a built-in way to recursively search this entire tree structure?

My current implementation is essentially a breadth first search, but I was curious whether mongodb/mongoid has more efficient implementation.

1 Answers
Related