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