updateOne and positional $ operator #10247
Unanswered
vineetdigit
asked this question in
Q&A
Replies: 0 comments
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.
-
MongoDB documentation explains the method of using positional $ operator to update a subdocument in an array using updateOne.
According to https://docs.mongodb.com/manual/reference/operator/update/positional/#mongodb-update-up.-
This method requires specifying a query document as well as update document.
I am able to successfully implement this using Mongoose.
However this method requires specifying a query document for following reason
You must include the array field as part of the query document.
But suppose I already have a document (and I don't want to query it again), how can I do this in Mongoose using the doc.updateOne? This API does not accept query document.
Beta Was this translation helpful? Give feedback.
All reactions