常见mongo命令

@(编程)

查询

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 
    }
);
原文地址:https://www.cnblogs.com/wardensky/p/5177349.html