jsn = {
"data":[
"Id":"123",
"qnty":[{"qId":"3","qItem":123},]
]
}
hi, i want to update document's using mongoose in nodejs, but unable to do so, what i want is to update the "qitem" of qnty array of object and insert similar other objects in update, my approach is below.
var doc = await model.findOne({"data.Id":x});
//if i have qnty object already present i want to update its value
doc.toObject().data[0].qnty[0].qItem = 100;
//i want to push many object this is just example
doc.toObject().data[0].qnty.push({"qId":"4","qItem":124});
doc.save();
you should use
model.update({"data.Id":x},{"data.qnty":doc.data[0]})
in place of doc.save() i think that will do the trick