Monday, August 27, 2018

mongodb - Updating a document field in mongo based on another field's value



Suppose I have two fields F1 and F2. I want to update F1 to become F1 + ", " + F2. Can I do so with a single update command in mongo?


Answer



No, you can't do that. You can't use expressions in mongodb updates. The only way is to fetch this document to the client, compose new field value there and issue a prepared update statement.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...