Last active
April 19, 2019 13:31
-
-
Save PoplarYang/26063b3b11cdb255fcccfbb6faa15d0a 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
| cfg = rs.conf() | |
| cfg.members[0].priority = 0.5 | |
| rs.reconfig(cfg) |
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
| # 1 删除 | |
| 删除指定记录 | |
| db.collection.remove({}) | |
| 删除collection | |
| db.collection.drop() | |
| 删除整个库 | |
| 先use,db.dropDatabase() | |
| # 2 通过用户密码登录 | |
| mongo -uusername -ppasswd --authenticationDatabase db | |
| # update | |
| db.col.update( | |
| { | |
| 'title':'MongoDB 教程' | |
| }, | |
| { | |
| $set:{ | |
| 'title':'MongoDB' | |
| } | |
| } | |
| ) | |
| # 正则 | |
| db.products.find( { sku: { $regex: /789$/ } } ) | |
| db.oplog.rs.find({"o2._id": /2018-12-12.png/}) |
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
| rs1:PRIMARY> use admin | |
| switched to db admin | |
| rs1:PRIMARY> db.runCommand({logRotate:1}); | |
| { "ok" : 1 } |
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
| db.products.remove( | |
| { qty: { $gt: 20 } }, | |
| { writeConcern: { w: "majority", wtimeout: 5000 } } | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment