When fetching a document with a specific property set to an ObjectID, add data from another document #2365
Unanswered
maziluradu
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The question is: mongoose able to do that? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a simple mongoose model defined like this:
I would like to implement a behavior where if I try to fetch a document (of this model) from my MongoDB database and that document includes a valid "clonesUserId" property, it combines the data from both documents and returns the combined information.
For example, if I have the following 2 documents:
.. when fetching the secondary user, the query actually would return the following:
Is there any clean way to do this besides manually adding code every time I am using "userModel.findOne(...)"? I would love if there was an implementation in the model's class only
Beta Was this translation helpful? Give feedback.
All reactions