Last active
November 21, 2018 06:13
-
-
Save lovellfelix/cd2428b80eb755892310 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Drop entire other collection | |
db.collection1.drop(); | |
//rename collection field | |
db.posts.update({}, {$rename: {"usernmae": "username"}}); | |
//Copy from one collection to another | |
db.collection1_backup.find().forEach(function(doc){ | |
db.collection1.insert(doc); // start to replace | |
}); | |
//Update multiple records | |
db.news.update({},{$set : {"user":ObjectId("55d3fccf989b991500658f07")}},{multi:true}) | |
//Add new field to collection | |
db.stream_radio.update({},{$set : {"active":true}}, | |
{upsert:false, | |
multi:true}); | |
//Add provider to user profile field if google-tokenId exist | |
db.users.update({"google-tokenId": { $exists: true } },{$set : {"profile.provider":"google"}},{multi:true}) | |
//remove field | |
db.users.update({}, {$unset: {gender: 1}}, {multi: true}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment