You’re close; you should use dot notation in your use of the $
update operator to do that:
Person.update({'items.id': 2}, {'$set': {
'items.$.name': 'updated item2',
'items.$.value': 'two updated'
}}, function(err) { ...
More Related Contents:
- Push items into mongo array via mongoose
- E11000 duplicate key error index in mongodb mongoose
- Mongoose: findOneAndUpdate doesn’t return updated document
- Mongoose populate vs object nesting
- Stop Mongoose from creating _id property for sub-document array items
- Populate nested array in mongoose
- Cannot overwrite model once compiled Mongoose
- mongodb/mongoose findMany – find all documents with IDs listed in array
- MongoError: The ‘cursor’ option is required, except for aggregate with the explain argument
- Mongoose Schema hasn’t been registered for model
- Mongoose findByIdAndUpdate not returning correct model
- Mongoose duplicate key error with upsert
- Mongoose (mongodb) batch insert?
- How can I use a cursor.forEach() in MongoDB using Node.js?
- Mongoose update without callback
- Model.find().toArray() claiming to not have .toArray() method
- How to fix ‘Error: querySrv EREFUSED’ when connecting to MongoDB Atlas?
- Mongoose optional search query parameters?
- Difference between MongoDB and Mongoose
- How to get all count of mongoose model?
- How can I save multiple documents concurrently in Mongoose/Node.js?
- Mongoose: CastError: Cast to ObjectId failed for value “[object Object]” at path “_id”
- Model.find() returns empty in mongoose [duplicate]
- nodejs mongodb object id to string
- How to reference another schema in my Mongoose schema?
- set field as empty for mongo object using mongoose
- Mongoose overwrite the document rather that `$set` fields
- Mongodb $lookup dynamic collection
- Mongoose complex (async) virtuals
- Create unique autoincrement field with mongoose [duplicate]