How can we replicate the following sql query in MongoDb?
update Person set Alias = Name;
where the Person table has the columns Alias, Name
I want the query to affect multiple rows. It doesn’t matter if the update query cannot support upserts, I only need to update & not insert.
Unfortunately, that functionality is not available in MongoDB. You will need to loop through the documents, updating them one-at-a-time, and doing a read-update pair.
If you want this to be concurrency-safe, you’ll need to implement some sort of locking; either optimistic or pessimistic.