个人总结的一些常用命令
db.getCollection(‘invoice_info’).find().count() //查询数据总数
db.invoice_info.find({uuid:“3088e706476c409d8de9b0b3e31d8bd2”}, {_id: 1, uuid: 1,phone: 1,addTime: 1}); //查询集合invoice_info 中的列
db.invoice_info.find({"_id":ObjectId(“5be159412ccb2000b7da4746”)}, {_id: 1, uuid: 1,phone: 1,addTime: 1}); //查询集合invoice_info中的列
db.invoice_info.find({"_id" :ObjectId(“5be14487bbff8956a37ead5f”)}).explain(true) //定位慢查询
db.getCollection(‘invoice_info’).find({uuid:“3088e706476c409d8de9b0b3e31d8bd2”}).explain(true) //查询某个文档信息
db.fpt1.createIndex({tuserid:1},{unique:true}) 创建唯一索引
db.fpt1.getIndexes() //查看索引
db.fpt1.dropIndex(“tuserid_1”) //删除索引
分页查询 limit:代表查询2个skip跳过几个
db.getCollection(‘invoice’).find({}).sort({“invoiceDate”:1}).limit(2).skip(2);