1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| db.getCollection('policy_content').find({})
# 条件查询 db.getCollection('policy_content').find({"task_id":1});
# Count db.getCollection('policy_content').find({"task_id":1}).count(); # 限制条数 db.getCollection('policy_content').find({"task_id":1}).limit(5); # 分页 db.getCollection('policy_content').find({"task_id":1}).limit(10).skip(5);; # OR db.getCollection('policy_content').find({$or:[{column: "2"}, {column1: "24"}]});
# 比较查询 $gt" 、"$gte"、 "$lt"、 "$lte" db.getCollection('policy_content').find({"task_id":1, "created":{"":10000}}).count(); db.getCollection('policy_content').find({'DataTime':{'$gte':1518278400}}).count()
# 时间 db.getCollection('policy_content').find({"task_id":1, "created":{$gte:"2021-09-01",$lte:"2021-9-11"}})
# 模糊查询 db.getCollection('policy_content').find({ "name" : /mongo/});
# 查询指定条件下指定列 db.getCollection('policy_content').find({}, {"column":1, "InMongoTimet":1});//查询column和InMongoTimet这两个字段
# 建索引 db.policy_content.createIndex({"index_id":1})
|