Dealing with ref and populate when updating document #11939
Unanswered
tamis-laan
asked this question in
Q&A
Replies: 1 comment
-
@tamis-laan can you please provide some code samples? Hard to provide any meaningful guidance without seeing the code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My system has one route that populates object A that contains an array of refs to object B. It returns this object from the route to the frontend.
At the frontend an extra object B is added to the array contained in object A to create A' . The updated object A' is then send back to a route on the backend.
In the backend object A is updated to reflect the new object A'. However this does not work as A' is a populated version of A.
What is the best way to deal with this situation. At the moment I reduce the array of B objects in A' to an array of ref B before sending it to the backend. Is this the best way of doing this? Does mongoose have some way to deal with this situation?
Beta Was this translation helpful? Give feedback.
All reactions