자주쓰는 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 });

댓글

  1. db.events.update({ expired: { $ne: true }}, { $set: { expired : false }}, { multi: true });

    답글삭제
  2. db.getCollection('players').update({manager: null}, { $set: { manager : ObjectId("xxxx") }}, { multi: true })

    답글삭제

댓글 쓰기

이 블로그의 인기 게시물

mongoDB admin 권한 설정방법 How to enable access control for mongo DB

Install pm2 via yarn globally