记录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"}})
转载注明出处
如果本文对你有帮助,请帮忙啦~~
打开支付宝首页搜“522901509”领红包,领到大红包的小伙伴赶紧使用哦!