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}}

)

扫描二维码关注公众号,回复: 877410 查看本文章

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

db.getCollection('student').update(

  {'name':'eggsy'},

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

)

猜你喜欢

转载自www.cnblogs.com/qiyc/p/9048584.html