Answers for "set with conditions in mongodb"

0

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
        }
    ]
)
Posted by: Guest on October-20-2021

Code answers related to "set with conditions in mongodb"

Browse Popular Code Answers by Language