MongoDB常用指令整理

 

1 查看集合的条数

db.httpRequestLog.count();

 

2 and查询

{$and:[{"requestUrl":"/sleep_reports/pad/report/upload"},{"requestParam.ring_sn":"P11E12210000035"}]}

 

3 or查询

{$or:[{"requestParam.ring_sn":"P11E12210000035"},{"requestParam.ring_sn":"P11E12210000036"}]}

 

in查询

{"zyzd":{$in:["胃痛"]}}

 

 

4 索引操作

创建索引:db.httpRequestServiceLog.ensureIndex({"createTime": 1},{expireAfterSeconds: 2592000});
查看索引:db.httpRequestLog.getIndexes();
删除索引:db.httpRequestLog.dropIndex("createTime");

 

 5 更新字段为另一个字段的值

db.patient.find({}).forEach(
    function(item){
      db.patient.update({"_id":item._id},{$set:{'shenfenzheng':item.cardId}},false,false);
    }
);

 

 








posted @   喻聪  阅读(32)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示