• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Update object values inside array where id is equal to inside Array

Resolved: Update object values inside array where id is equal to inside Array

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Supposedly I want to update the object values of array of a document, but first I will need to look for its id first, heres the structure of document
I want to update the status of notifications under that user where the objectId must be equal to inside the result array
this should yield this result after the update
Heres what Ive done so far but Im not getting the result i need

Answer:

You can use $map to iterate through notifications and use $cond and $mergeObjects to perform the conditional update.
Here is the Mongo Playground for your reference.

If you have better answer, please add a comment about this, thank you!

aggregation-framework javascript
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: significance letter above bar graphic in wrong order

01/04/2023

Resolved: VBA – Applying border around the areas with value/text

01/04/2023

Resolved: How can I implement a function depending on picked up items?

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.