常见mongo命令

时间:2022-05-20 12:57:31

@(编程)

查询

db.getCollection('SalaryEntity').find({"Month" : "201601"})
db.getCollection('SalaryEntity').find({"Month" : "201601", "DepartName" : "运维与管理软件部"})
db.getCollection('SalaryEntity').find({"Month" : "201601"},{"DepartName":true})

更新

db.getCollection('PersonBaseInfo').update(
// query
{
"DepartName" : "MIS与互联网部"
}, // update
{
"$set":
{
"DepartName" : "互联网与无线电项目部"
}
}, // options
{
"multi" : true, // update only one document
"upsert" : false // insert a new document, if no existing document match the query
}
);