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 })
网友评论