2021-11-26

MongoDB - Update field value using another field's value

db.test1.update(

    {

        "filter_field": 1,

    },

    [

        {$set: {

            "target_field": "$source_field"

        }}

    ]

); 

2021-11-12

MongoDB - Project a value based on the existance of a field

 {$cond: {

    if: {$eq: [ {$ifNull: ["$FIELD_NAME", null]}, null ]},

    then: NumberInt(0),

    else: NumberInt(1) 

}},