zoukankan      html  css  js  c++  java
  • mongodb update ()命令

    1).update()命令

    db.collection.update( criteria, objNew, upsert, multi )

    criteria : update的查询条件,类似sql update查询内where后面的
    objNew   : update的对象和一些更新的操作符(如$,$inc...)等,也可以理解为sql update查询内set后面的
    upsert   : 这个参数的意思是,如果不存在update的记录,是否插入objNew,true为插入,默认是false,不插入。
    multi    : mongodb默认是false,只更新找到的第一条记录,如果这个参数为true,就把按条件查出来多条记录全部更新。

    例:
    db.test0.update( { "count" : { $gt : 1 } } , { $set : { "test2" : "OK"} } ); 只更新了第一条记录
    db.test0.update( { "count" : { $gt : 3 } } , { $set : { "test2" : "OK"} },false,true ); 全更新了
    db.test0.update( { "count" : { $gt : 4 } } , { $set : { "test5" : "OK"} },true,false ); 只加进去了第一条
    db.test0.update( { "count" : { $gt : 5 } } , { $set : { "test5" : "OK"} },true,true ); 全加进去了
    db.test0.update( { "count" : { $gt : 15 } } , { $inc : { "count" : 1} },false,true );全更新了
    db.test0.update( { "count" : { $gt : 10 } } , { $inc : { "count" : 1} },false,false );只更新了第一条

  • 相关阅读:
    汇编实现点亮Led灯(2440)
    BootLoader(2440)核心初始化代码
    学习单片机的正确方法(转载)
    ARM-汇编指令集(总结)
    BootLoader的架构设计
    统计单词数(WordCount)
    OPcache
    phpcon china 2017听讲总结
    php-fpm进程内存泄漏
    mysql字符串的隐式转换导致查询异常
  • 原文地址:https://www.cnblogs.com/ElvinLong/p/4371904.html
Copyright © 2011-2022 走看看