Set With Conditions In Mongodb

[Solved] Set With Conditions In Mongodb | Perl - Code Explorer | yomemimo.com
Question : set with conditions in mongodb

Answered by : breakable-bison-1h7dk77elwrh

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 } ]
)

Source : https://stackoverflow.com/questions/30385663/mongodb-set-field-value-using-if-else-during-document-update | Last Update : Wed, 27 Oct 21

Answers related to set with conditions in mongodb

Code Explorer Popular Question For Perl