mongoDB数据库查询实用语句

查询source_id属性存在的元组

db.getCollection(‘数据库名’).find({source_id:{$exists:true}})

db.getCollection(‘mqtt_log’).find({source_id:{$exists:true}})

查询source_id属性为具体数值的元组

db.getCollection(‘api_log’).find({source_id:“777779014”})

查询source_id属性存在且create_time在某个时间段的元组

db.getCollection(‘数据库名’).find({source_id:{$exists:true}, create_time:{$gte: ISODate("2021-01-01T00:00:00Z"),$lte: ISODate("2021-01-28T00:00:00Z")}})

db.getCollection(‘api_log’).find({source_id:“777779014”, create_time:{$gte: ISODate("2021-01-01T00:00:00Z"),$lte: ISODate("2021-01-28T00:00:00Z")} })

db.getCollection(‘mqtt_log’).find({source_id:“1144606801”, create_time:{$gte: ISODate("2021-01-01T00:00:00Z"),$lte: ISODate("2021-01-28T00:00:00Z")} })

猜你喜欢

转载自blog.csdn.net/weixin_43361722/article/details/114301593