Reputation: 161
i want to push data to a list inside a document along with updating some other keys.
one document in db:
{
"_id":"1",
"name" : "prayas Agrawal",
"abc" :{
"is_completed":false,
"status":"failed",
"message": ["xyz"]
}
}
this is my document structure
and i want to make the status:"pass", "is_completed": true and push a message in message "succes at 20:12"
Upvotes: 0
Views: 103
Reputation: 22974
db.test.update({ //Find
},
{
$set: {//update
"abc.is_completed": true,
"abc.status": "pass"
},
$push: {//push
"abc.message": "succes at 20:12"
}
})
Upvotes: 1