美文网首页
mongodb(不一样的sql)

mongodb(不一样的sql)

作者: 财务自由_lang | 来源:发表于2017-08-03 09:46 被阅读0次

    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 })

    相关文章

      网友评论

          本文标题:mongodb(不一样的sql)

          本文链接:https://www.haomeiwen.com/subject/lxiulxtx.html