zoukankan      html  css  js  c++  java
  • 记录MongoDB常用查询

    {$and:[{"flag" :{ $ne:"1"}},{"flag" :{ $ne:"0"}}]}  // flag不等于1 也不等于0
    {$or:[{"flag" :{ $ne:"1"}},{"flag" :{ $ne:"0"}}]}  // flag不等于1 或者不等于0
    db.xx_spider_agent.update({'tag':'111'},{$set:{'tag':'0'}},{multi:true})

    db.wuba_SaleHouseList_20180716.aggregate([{$group : {_id : "$city", num_tutorial : {$sum : 1}}}]) = select city,count(*) from wuba_SaleHouseList_20180716 group by city 常规的聚合统计

    db.anjuke_houseranking_20180717120000.aggregate([{$group : {_id : {name:"$city",st:"$type"}, count : {$sum : 1}}}]) = select city,type,count(*) from wuba_SaleHouseList_20180716 group by city ,type

    db.lianjia_showlooks.find({"showings":{$type:16}}).forEach(function(x){x.showings=String(x.showings);db.lianjia_showlooks.save(x)}) 替换int类型的字段为String 类型

    db.wuba_houseranking_20180913140000.aggregate([
    {$group:{"_id": { "city" : "$city", "type": "$type",} ,"number":{$sum:1}}},
    {$project:{"_id": false, "city" : "$_id.city", "type" : "$_id.type","number" : true}},
    {$sort:{"number":-1}},
    ])

    db.xms_orgID.updateMany({},{$set:{"tag":"1"}})

  • 相关阅读:
    按需导入NavMenu无法使用情况解决办法
    如果要使用另一台电脑作为服务器,注意关掉防火墙
    mongoose学习
    koa2的学习
    vue中swiper的使用
    447. Number of Boomerangs
    33. Search in Rotated Sorted Array
    461. Hamming Distance
    392. Is Subsequence
    412. Fizz Buzz
  • 原文地址:https://www.cnblogs.com/tnsay/p/9014823.html
Copyright © 2011-2022 走看看