Hello @Dev_Ops, you need to use arrayFilters
option of the update operation to update specific element of an array based upon a condition matching the array element’s field (in your case the userId
field).
See examples from documentation: Update Specific Elements of an Array of Documents
Also, see these posts with similar questions and answers:
- This post is from this site: Nested arrays how to do query and update?
- This has a
mongo
shell query solution and is from Stack Overflow: How to add a json in a nested array of a mongodb document using Spring?