자주쓰는 MongoDB 명령어
# remove a document on MongoDB
$ db.<collection>.remove({ _id: ObjectId("id")});
# update a document on MongoDB
# change name to "bao"
$ db.<collection>.update({ _id: ObjectId("") }, { $set: { name: "bao" }});
# update multi documents on MongoDB
# find all documents which type is not "t" and then change their type to "n"
$ db.<collection>.update({ type: { $ne: 't' }}, { $set: { type : ''n" }}, { multi: true });
db.events.update({ expired: { $ne: true }}, { $set: { expired : false }}, { multi: true });
답글삭제db.getCollection('players').update({manager: null}, { $set: { manager : ObjectId("xxxx") }}, { multi: true })
답글삭제