Mongoid recursively finds inline document

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

I have the following setup:

The group includes many posts. Post recursively inserts many posts.

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

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

+6
source share
1 answer

The current Mongoid documentation mentions that this is possible and shows how to do this, see the Recursive Nesting section. This only works in embedded documents.

0
source

Source: https://habr.com/ru/post/921167/


All Articles