Whenever I attempt to implement the code snippet below for MongoDB, I encounter this error:
var updateDoc = {
$set: {
energy: {
$cond: {
if: { $gt: [ { $add: [ "$energy", 20 ] }, 100 ] },
then: 100,
else: { $add: [ "$energy", 20 ] }
}
}
}
}
Is there a solution to resolve this issue?