mongo使用方法整理
2019-11-25 本文已影响0人
a9b854aded01
更新某个string字段整理后改为int类型字段
db.getCollection("wenku").find({"file_size":/MB/}).forEach(function(x){
x.file_size = x.file_size.replace("MB","");
x.file_size = NumberInt(x.file_size)*1024
db.getCollection("wenku").save(x)
print(x);
})
嵌套查询
db.getCollection("wenku").find({"app_id":13,"history_record._id":{$type:2},"file_size":{$type:2},"categories":{$in:[ObjectId("5271d708f8b1692975e84ae0"),ObjectId("55d9785609d8143941494686"),ObjectId("573a8c0fe657f1d9500409d4"),ObjectId("58c0a7cde657f1081961537d")]}})