Skip to content

Instantly share code, notes, and snippets.

@jackyshan jackyshan/mogno.sql
Created Dec 28, 2018

Embed
What would you like to do?
mongodb日常操作
//查找单个字段
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
You can’t perform that action at this time.