Append a string to the end of an existing field in MongoDB

后端 未结 6 1285
灰色年华
灰色年华 2020-12-02 23:22

I have a document with a field containing a very long string. I need to concatenate another string to the end of the string already contained in the field.

The way I

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 00:10

    db.getCollection('').update(
        // query 
        {},
    
        // update 
        {
            $set: {:this.+""}
        },
    
        // options 
        {
            "multi" : true,  // update only one document 
            "upsert" : false  // insert a new document, if no existing document match the query 
        });
    

提交回复
热议问题