set with conditions in mongodb
db.collectionname.aggregate(
[
{
$set: { //Compute the new value
'ResultField': {
$cond: {
if: {
$lt: ['$ScoreField', 40]
},
then: "Fail",
else: "Pass"
}
}
}
},
{
$out: 'collectionname' //Update the records in collection
}
]
)