Created
December 28, 2018 07:57
-
-
Save jackyshan/ef63c54ee7efa1f034f8c39b6df5aaf8 to your computer and use it in GitHub Desktop.
mongodb日常操作
This file contains 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.users.find({_id:ObjectId("5c25b4fdc32ea0b85da2a3bc")}, {"address":1}) | |
//更新数组 | |
db.users.update({_id:ObjectId("5c25b504c32ea0b85da2a3bd")}, {$push:{address:ObjectId("5c25cf01c32ea0b85da2a3c8")}}) | |
//一对多关系查询 | |
var result = db.users.findOne({_id:ObjectId("5c25b504c32ea0b85da2a3bd")}, {"address":1}) | |
db.address.find({_id:{$in:result["address"]}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment