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 31 32 33 34 35 36 37 38 39 40 41 42 43
| db.selectname.find({}).count()
db.shiXinPeople.find({}).count()
/*
*复合索引唯一
*db.People.ensureIndex({"Name":1,"Age":1},{"unique":true,"dropDups":true})
*/
db.selectname.ensureIndex({"selectName":1,"city":1},{"unique":true,"dropDups":true})
db.shiXinPeople.ensureIndex({"loc":1},{"unique":true,"dropDups":true})
/*
*update 更新操作
*db.classes.update({"count":{$gt:20}},{$set:{"name":"c4"}},false,true)
*/
db.selectname.find({"selectState" : "0"}).limit(2)
db.selectname.update({},{"$set":{"start":0,"selectState":"0"}},false,true)
db.selectname.update({},{"$unset":{"SelectState":""}},false,true)
db.selectname.update({},{$set:{"selectState":"0"}},false,true)
db.selectname.aggregate({"$group":{"_id":{"selectState":"$selectState"},"count":{$sum:1}}})
db.selectname.find({"selectState":"1","start":{$gte:1000}})
db.selectname.find({"selectState":"1"})
db.shiXinPeople.find({}).count()
db.shiXinPeople.distinct('loc')
db.shiXinPeople.aggregate([{"$group":{"_id":{"loc":"$loc"},"count":{$sum:1}}},{"$match":{"count" : {"$gt" : 1}}}],{ allowDiskUse: true })
|