Hello Im having a weird issue
Ive looked in a few previous questions but ive ran into an issue
Basically I have a document containing a boolean
This boolean is called enabled
Id like to switch it using the findOneAndUpdate function
{ $set: { enabled: { $not: "$enabled" } } }
This is what ive come to according to previous questions
However when I attempt it this is the result
enabled: { '$not': '$enabled' }
Here is my full code
db.findOneAndUpdate({
_id: "Sample"
}, {
$set: {
enabled: {
$not: "$enabled"
}
}
}, {
new: true
}, function(err, result) {})