根据日期查询数量
db.getCollection("api_invocation_logs").find({"createdDate":{"$gte":ISODate("2024-01-09T00:00:00Z"),"$lt":ISODate("2024-01-10T00:00:00Z")}}).count()
查看某个字段不为空的数据
db.getCollection('waimao_company_info').find({'numberOfEmployees':{$ne:null}})
查看某个表所有字段
mr = db.runCommand({
"mapreduce": "waimao_company_info",
"map": function() {
for (var key in this) {
emit(key, null);
}
},
"reduce": function(key, stuff) {
return null;
},
"out": "waimao_company_info" + "_keys"
})
db[mr.result].distinct("_id")
模糊查询
db.getCollection("rocket").find(
{emails:/@/}
)