mongodb - use db.update to update all the documents -
I want to use a Mongo Shell to update some documents that looks like this: < ("54265f801681140a66ca45de"), "Username": "000000002-xqsh", "Name": "xxxxx", "__v": 0}
 I want to change the dash     If you want to change to all user names,   -  to enter  _  to enter  usernames . Can I make it a Mongo shell? My Mongo shell version is as follows:   
 & gt; Version () 2.6.4     
 db.c.find (user name : / - /}, {user name: 1}) .for (function (e) {var user name = e.username.replace ("-", "_"); db.c.update ({_ id : E._id}, {$ set: {username: username}})}}    Use the 
 db.c.find ({user name: / - /}, {username}: 1}). Pre (function (e) {var username name = e.username.replace (/ - / g , "_"); Db.c.update ({_ id: e._id}, {$ set: {username: users Class Name}});});    
 
  
Comments
Post a Comment