Translating SQL update to MongoDB

Hello, I’m quite used to SQL, but new to MongoDB.
Before asking I searched a lot on the Internet and in this forum, but didn’t come up with even some method to translate the following kind of SQL update into MongoDB:

UPDATE Authors SET lastName=REPLACE(lastName, ‘DE’, ‘OF’) WHERE city LIKE ‘%new%’

Is there any way to perform such an update through the simple shell? Maye I overlooked some relevant topic, being a newbie, even addressing to a relevant post could help!

Thank you very much in advance!

You can use the db.collection.updateMany mongo shell method to update a collection. Also, note that there are other update methods.

The main arguments of the update method are the filter where you specify the condition, and the update where you set the modified values.

There is no “LIKE” operator in MongoDB. But, you can use the $regex for specifying the same query condition.

For replacing the character string you need to use the Aggregation Pipeline for the update. Aggregation Framework provides string expression operators to find / replace the characters.

Wow, thank you very much, I appreciate the links a lot! :slightly_smiling_face:
I’ll have look, now I have a path to follow!
Thanks again!!!