查询文档列表
db.getCollection('documentinfo').find({"mustRead": true, "docStatus": "online", "$or": [{"docPermissionType": "public"}]}).count()
修改文档字段名
// 单个修改 db.getCollection('exam').update({_id: "1f51310a-518f-4816-8518-302f4a8bd437"}, { $rename: { "employee_id": "employeeId" }}) // 批量修改 db.getCollection('exam').updateMany({}, { $rename: { "employee_id": "employeeId" }}) 参加:https://docs.mongodb.com/manual/reference/operator/update/
更新,修改字段
db.getCollection('exam').updateOne({_id: "1f51310a-518f-4816-8518-302f4a8bd437"}, {$set: {"isPassed": false}} )
查询文档中某个字段是否存在
db.getCollection('userinfo').find({ "isPassed": { $exists: true } }).count()
删除文档中某个字段
// 删除单个 db.getCollection('userinfo').delete({_id: "1f51310a-518f-4816-8518-302f4a8bd437"}, {$unset: {"duhuo": ''}} ) // 批量删除 db.getCollection('userinfo').deleteMany({}, {$unset: {"duhuo": ''}} )