Update deeply nested array in mongodb
You can try with arrayFilters
in mongodb
var mongoose = require('mongoose')Temp.update( { "_id" : mongoose.Types.ObjectId("5b62c772efedb6bd3f0c983a") }, { "$set": { "inspection_data.$[e1].locationAspects.$[e2].comments.$[e3].images.$[e4].title": "TableFan" }}, { "arrayFilters": [ { "e1._id": mongoose.Types.ObjectId("5b62c772fa02622a18655e7b") }, { "e2._id": mongoose.Types.ObjectId("5b62c772fa02622a18655e80") }, { "e3._id": mongoose.Types.ObjectId("5b62c772fa02622a18655e81") }, { "e4.id": "1" } ]})
Note: You have to cast
_id
toObjectId