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@gmail.com",
"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
}
]
}
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 .
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.