What are the methods of mongodb query table fields, string interception, and updates
This article mainly introduces mongodb query table fields, string interception and update methods, the text is very detailed, has a certain reference value, interested friends must read!
The update() method is used to update existing documents. The syntax format is as follows:
db.collection.update( , , { upsert: , multi: , writeConcern: } )
Parameter Description:
query : update query conditions, similar to sql update query after where.
update : update object and some newer operators (such as $,$inc...) It can also be understood as sql update query after set.
upsert : Optional, this parameter means, if there is no update record, whether to insert objNew,true for insert, default is false, do not insert.
multi : Optional, mongodb default is false, only update the first record found, if this parameter is true, update all the records found according to the conditions.
writeConcern : Optional, the level at which the exception is thrown.
Example:
Picture replacement address, fuzzy query first, then replace
db.pfs_merchants.find({'logo_url': /10.2.121.170/}).forEach(function(user) { user.logo_url = user.logo_url.replace("10.2.121.170","10.128.3.80"); print(user.logo_url); db.pfs_merchants.update({"_id":user._ id},{$set:{"logo_url":user.logo_url}}); }) The above is "mongodb query table fields, what is the method of string interception and update" All the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!