I am trying to write a query to update a date in mongo to be the same as an existing date inside of the same record based on some logic. I have a simple step that I am stuck on how do I access the value?
db.getCollection("MyCollection").updateMany({
//SOME LOGIC HERE
{
"$set":{"updatedTs": "$$createdTs"}
},{multi:true}
)
This returns updatedTs being equal to the literal string "$$createdTs" and not the value stored. The closest I've found to my query is this forum question but the page linked no longer exists: https://www.mongodb.com/community/forums/t/updatemany-in-mongodb-using-value-of-other-field/99555
What am I missing here?