Nested Relations in subdocuments #723
Replies: 2 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
-
First of all, thanks to both for taking the time answering my feature request with such a detailed answer. Also to @roman-right for the awesome ODM :-). The reason I wanted this 'weird' structure is just because I was trying to write a small, read-only service to retrieve data from an already existing collection. It has a similar structure to the one I have described/oversimplified. So after realizing that what I wanted is already partially possible, I guess that the feature request would be "allow to specify links that are only an ObjectID, letting the developer specify the target collection". This would allow more conveniently reading with Beanie data saved by MongoEngine, which creates links just using an ObjectID. But I can already see that this clashes with Beanie's design. I guess my only chance is using an aggregation pipeline. Thanks again to both, and I wish you a great weekend. |
Beta Was this translation helpful? Give feedback.
-
Currently, the following case works with beanie. I can retrieve a list of todos using the get(fetch_links=True) method.
So far, so good. But let's say I would have this instead:
A document of the TodoList would look in the db lke this:
I would have no way to retrieve those links without having to iterate the list of todo_items and call fetch for each item, which is super slow.
So my feature reqest would be:
"Support automatically fetching related objects for Links in nested SubDocuments, or document an efficient alternative" :-)
Beta Was this translation helpful? Give feedback.
All reactions