随笔 - 73  文章 - 0  评论 - 5  阅读 - 10万

mongo查询命令

复制代码
db.t_comment.find({
        object_id: 6,
        object_type: "topic",
        status: 0,
        replied_comment_id: null
    })
    .sort({
        _id: -1
    })
    .limit(100)
db.playCompleted.aggregate([{$match:{_id: 3046695,}},{ $unwind:"$records"},{$match:{$records.completeCount:1}}] )

db.t_comment.find({
        object_id: 14,
        object_type: "topic",
        status: 0,
        topic_reply_id: "5f2bc38d9da72a000eea3150"
    })
    .sort({
        _id: -1
    })
    .limit(100)

db.t_info.find().count();


db.t_info.find({
        detailType: 1
    })
    .sort({
        _id: -1
    })
    .limit(100)

db.resource.update({oldId:"1"},{$set:{"mainType":1}})

db.resource.updateMany({type:{$in:[1,4]}},{$set:{"businessZone":1}})

db.resource.updateOne({ _id: ObjectId("639971631d5ed1320fd87485") }, {
    $set: {
        "authorIds": [
            "6392d6b7e836f33968d95368"
        ]
    }
});
db.getCollection('resource').aggregate([{$match:{type:{$in:[1,4]}}}, {$group: { _id : '$oldId', count: { $sum : 1 } } },{$match: {count:{ $gt : 1}}}])

db.t_team.find({teamMembers:{$elemMatch:{userId:11111}}}})

db.resource.update({oldId:"1"},{$set:{"mainType":1}})


db.t_comment.find({
        object_type: "topic",
        user_id: 418279610,
        status: 0
    })
    .sort({
        _id: -1
    })
    .limit(100)
db.resource.find({
    type: {
        $in: [1,4,20]
    },
    publishStatus:1,
    auditStatus:2,
    classifyIds:{$exists:false}
}).count();

db.resource.find({
    type: {
        $in: [1,4,20]
    },
    delFlag:false,
    publishTime:{$lt:ISODate("2023-07-28T00:30:00.000+08:00")},
    classifyIds:{$nin:["5f4e75909c215b58a2350577","62b435cbd6a314240e653e3d","627a194a0e9acb4305798d03","5ee0ec8d747f4ec79984e535","627a178e975649281a19fdce","6285a6820e9acb4305798db4","627a16ed975649281a19fdcd","6285a66f0e9acb4305798db3","627a1869975649281a19fdcf","6285a65a8f9ce003b059395e","627a190b0e9acb4305798d02","6285a68d975649281a19fe74","627a175f0e9acb4305798d01","6285a678eb29f35d5706b330"]}
})count();

切分数据后,再查下
db.playCompleted.aggregate([{$match:{_id: 3046695}},{$unwind:"$records"},
{$match:{'records.completeCount':{$exists:false}}}])

统计数量
db.t_resource_id.find({
    objectType: 10,
    subType: 2
}).count();

db.resource.find({
    type: {
        $in: [2,7]
    }
}).count();

创建集合,创建索引
db.createCollection("t_mobile_device");
db.t_mobile_device.createIndex({mobile: 1}, {background: true});
db.t_mobile_device.createIndex({sm_device_id: 1}, {background: true});
db.t_mobile_device.createIndex({relateType: 1}, {background: true});
db.t_mobile_device.createIndex({create_time: 1}, {background: true});


db.t_team.find({teamMembers:{$elemMatch:{userId:11111}}}})

启动服务
cd /usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.2.8/bin/
mongod --config ../mongodb.conf
复制代码

 

posted on   怦然丶心动  阅读(33)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
历史上的今天:
2018-09-19 Intellij Idea 2017 字体模糊解决方案
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示