im trying to make an update on my bd, but the problem is that i dont have an id per object, the only thing i can identify by its the "description" property. I want to update that property value but first i have to find it and update it as well, this is the json
{
"_id": {
"$oid": "637c1064a2f047f5ab75ac42"
},
"title": "this is a list",
"todo": [
{
"completed": false,
"description": "a normal task"
},
{
"completed": false,
"description": "this is another task"
},
{
"completed": false,
"description": "another task"
}
],
"username": "lucas",
"__v": 3
}
This is what im trying to do, im trying to update the property description with a new description, but first i have to find the same element that matches with whats in the body.
List.findOneAndUpdate(
{todo: {description: req.body.description}},// trying to find it here
{$set:{todo : {description: req.body.newDescription}}}, //trying to change it here
function(err, response) {
console.log(err,response)
}
)