美文网首页
mongo使用方法整理

mongo使用方法整理

作者: a9b854aded01 | 来源:发表于2019-11-25 10:31 被阅读0次

更新某个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")]}})

相关文章

网友评论

      本文标题:mongo使用方法整理

      本文链接:https://www.haomeiwen.com/subject/dksdwctx.html