'Combine one condition can we update increment and decrement mongodb base on condition?
Can we update increment and decrement mongodb base on condition?
db.collection.update({
_id: ObjectId("60e80c96b9c55e7a01898f5c"),
"watched.3": {
$exists: true
}
},
{
$inc: {
fans: 1
}
})
if watched.3 exists then
remove 3 and fans = -1
else
add watched.3 and fans +2
Please guide
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
