i'm trying to write an update query to update a column/filed of a collection. My collection has 4 fields: _id, name, date1, date2.
I'm trying to write an update query to set date1 = date2 and i tried using inner query as shown below but didn't work.
db.myCollection.updateMany(
{},
{
'$set':
{
'date2': db.myCollection.find({},{date1:1, _id:0}).limit(1)
}
}
);