0

I want to make an update into an array nested inside of an object inside of another array. This is the find method that worked for me to retrieve the object I am interested in:

db.getCollection('messagings').find({
id: '563f8ed864e68e4c200bed45', 
missions : {
    '$elemMatch' : {
        id: '563f8ed864e68e4c200bed46', 
        messages : {
                '$elemMatch' : {
                        timestamp : ISODate("2015-11-09T15:32:30.615Z")
                    }
            }
        }
     }
})

And I would like to update an element inside of an element of messages and I tried like this but obviously it didn't work...

{'mission.$.messages.$.message' : 'How are you ?'}

How can I make the update using mongoose in nodejs.

2
  • I saw that question but it didn't help me to much. Commented Nov 10, 2015 at 9:10
  • In short, it's not possible to do such an update using multiple $ positional operators unless you implement a hacky workaround using the forEach() method as prescribed in the other answer. There is an open JIRA ticket for that here. Commented Nov 10, 2015 at 9:15

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.