I'm looking to update something in my DB, but I need to use data in the object in the DB.
Here is what I would like to do :
score.findOneAndUpdate({name: "global"}, {$set:{score: score+1}})
and here is what it looks like in DB :
{
name: "global"
score: 1
}
So I need to find global, and increment the score by one and update it to obtain
{
name: "global"
score: 2
}
I know that I could first, find and store the data, and after an update, but how can I do it once with findAndUpdate()?