zoukankan      html  css  js  c++  java
  • mongodb修改器

    1.$inc: 对数字字段内容进行修改

    db.getCollection('student').update(

      {'age':19},

      {$inc:{'score':-20}}

    )

    2.$set :对字段内容进行修改

    3.$unset :对字段内容进行删除

    db.getCollection('student').update(

      {'name':'eggsy'},

      {$unset:{'score':1,'age':1}}

    )

    4.$push : 追加内容,数组

    db.getCollection('student').update(

      {'name':'eggsy'},

      {$push:{'course':'数学'}}

    )

    5.$pushAll : 一次追加多个内容到数组中

    db.getCollection('student').update(

      {'name':'eggsy'},

      {$pushAll:{'course':['英语','马列']}}

    )

    6.$addToSet : 向数组里面增加一个新的内容,只有当内容不存在的时候,才会增加

    db.getCollection('student').update(

      {'name':'eggsy'},

      {$addToSet:{'course':'英语'}}

    )

    7.$pull : 删除数组中指定内容

    db.getCollection('student').update(

      {'name':'eggsy'},

      {$pull:{'course':'英语'}}

    )

    8.$pullAll :一次性删除数组多个内容

    db.getCollection('student').update(

      {'name':'eggsy'},

      {$pullAll :{'course':['英语','语文']}}

    )

  • 相关阅读:
    python 冒泡排序
    python 文件操作
    20180401 lambda表达式
    python 全局变量 局部变量
    python 参数
    window.open
    正则表达式
    应用环境操作
    python 十大经典排序算法
    W3C------JS
  • 原文地址:https://www.cnblogs.com/qiyc/p/9048584.html
Copyright © 2011-2022 走看看