码迷,mamicode.com
首页 > 其他好文 > 详细

常用mongo语句

时间:2017-02-09 16:02:15      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:size   creat   remove   last   sage   inf   init   绑定   ruid   

只列出指定字段
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}
})

常用mongo语句

标签:size   creat   remove   last   sage   inf   init   绑定   ruid   

原文地址:http://www.cnblogs.com/simadi/p/6382289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!