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.

exilonX
  • 1,712
  • 3
  • 26
  • 50
  • I saw that question but it didn't help me to much. – exilonX Nov 10 '15 at 09: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**](http://stackoverflow.com/a/18721690/122005). There is an open JIRA ticket for that [**here**](https://jira.mongodb.org/browse/SERVER-831). – chridam Nov 10 '15 at 09:15

0 Answers0