MongoDB 用Robomong可视化工具操作的 一些简单语句

一、数据更新

db.getCollection('表名').update({ "字段":{$in:["值"]} },

//更新条件 {$set:{ "字段":"值", "字段":"值" //需要更新的数据 }},true,true //这里用法请看示例1下方的备注 ) 示例1:把表名为“aa”的表中字段"a"的值为“1”的数据更新两个字段的数据如下 db.getCollection('aa').update({ "a":{$in:["1"]} }, {$set:{ "state":"11111", "remark":"测试用的" }},true,true ) 备注: 只更新第一条记录: 1 db.col.update( { "count" : { $gt : 1 } } , { $set : { "test2" : "OK"} } );  全部更新: 1 db.col.update( { "count" : { $gt : 3 } } , { $set : { "test2" : "OK"} },false,true ); 只添加第一条: 1 db.col.update( { "count" : { $gt : 4 } } , { $set : { "test5" : "OK"} },true,false ); 全部添加加进去: 1 db.getcollection.update( { "symbol" : "ZC1801" } , { $set : { "symbol" : "ZC801"} },true,true ); 全部更新: 1 db.col.update( { "count" : { $gt : 15 } } , { $inc : { "count" : 1} },false,true ); 只更新第一条记录: 1 db.col.update( { "count" : { $gt : 10 } } , { $inc : { "count" : 1} },false,false ); 我常用的语句备注 --------------------- 本文来自 ls13552912394 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/ls13552912394/article/details/78854398?utm_source=copy

posted @   码海兴辰  阅读(25)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示