常用mongo语句

只列出指定字段
db.getCollection('PUBLICACCOUNTS').find({},{NickName:1,UserName:1,FID:1,_id:0})
获取微信公众号列表
db.getCollection('RELATIONALINFO').find({oidOrUid:{$ne:""},"folderInfo.available":1,sourceId:{$ne:""},accountType:1,ownerId:{$in:[0,1]}})
删除全部微信文章
db.getCollection('FollowMessage').remove({source:"weixin"})
修改微信公众号的lastPublicTime,lastGrabbeTime
db.getCollection('RELATIONALINFO').update({accountType:1},{$set:{lastPublicTime: ISODate("1999-12-31T16:00:00.000Z"),lastGrabbeTime: ISODate("1999-12-31T16:00:00.000Z")}},{multi:true})
获取绑定了3个folder的账号
db.getCollection('RELATIONALINFO').find({folderInfo:{$size:3}})
列出指定字段 排序
db.getCollection('FollowMessage').find({source:"weixin"}, {originalId: 1,"data.title": 1, _id:0,publishedAt:1 }).sort({publishedAt:-1})
获取广华的微博
db.getCollection('FollowMessage').find({oidOrUid:"2244734372"}).sort({createdAt:-1})
查找某些台的歌曲 in
db.getCollection('FollowMessage').find({stationId:{$in:["97105541-2563-E411-A33D-AC853D9F52F0","6a396fc0-5465-e411-a33d-ac853d9f52f0","bd6104a9-30c7-43c8-b907-d59911be5081","d862ce91-661c-4e50-b055-a4f901308274","e92132ce-952b-e511-b870-a35aa304d87f","6b4a168f-ba09-e511-b870-a35aa304d87f","4e7e41a0-653a-e511-b870-a35aa304d87f","232d2efb-1363-e411-a33d-ac853d9f52f0","3b2d490a-89a0-4f2d-9815-a4fa0129728e"]}})
根据来源进行分类统计 group
db.getCollection('FollowMessage').group({
key:{'source':1},reduce:function(doc,aggr){aggr.count++},initial:{'count':0}
})

posted @   simadi  阅读(849)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示