Reputation: 187
All I want is to update the value of the field "done" to "true"
I m developping with nodejs
here is the document :
{
"_id" : ObjectId("5a730e55114dbc2a0455c630"),
"email" : "[email protected]",
"password" : "12356789",
"tasks" : [
{
"title" : "new to do ",
"description" : "new something ",
"date" : "2018-02-07T18:16:29.469Z",
"done" : false
},
{
"title" : "new to d odo ",
"description" : "dod ododoododododo",
"date" : "2018-02-07T18:25:14.881Z",
"done" : false
}
]
}
Upvotes: 2
Views: 4904
Reputation: 308
you can use
$push
$set
$addToSet
you can use these operators to insert any object or any value to an array in the mongoose model.
Upvotes: 0
Reputation: 3151
Something like this should work:
db.collectionName.update({
"tasks.title": "new to d odo "
}, {
$set: { "tasks.$.done": true }
})
You can check more details in the documentation.
Upvotes: 5