记录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"}})

 

posted on 2018-05-09 16:02  山高似水深  阅读(240)  评论(0编辑  收藏  举报

购买方式 点击下面图标购买