I answered this question
I couldn't explain the reason why the same field cannot be used in update(aggregate) in the order of set then unset.
That looks valid to me at first sight. Since aggregation operator[] is mentioned, I believe that $set can use that $intField and then it can $unset.
db.getCollection('name').update({
"bid": "3860"
},
{
[
{
"$set": {
"tl": {
$add: [
{
$multiply: [
"$intField",
24*60*60*1000
]
},
"$dateField"
]
}
}
},
{
"$unset": 'intField' //Here
}
]
}
})
Please help me to understand this.