当前位置:Gxlcms > 数据库问题 > MongoDB,从数组中删除对象

MongoDB,从数组中删除对象

时间:2021-07-01 10:21:17 帮助过:2人阅读

{
   _id: 5150a1199fac0e6910000002,
   name: ‘some name,
   items: [{
      id: 23,
      name: ‘item name 23‘
   },{
      id: 24,
      name: ‘item name 24‘
   }]
}

删除代码
db.mycollection.update(
    {‘_id‘: ObjectId("5150a1199fac0e6910000002")}, 
    { $pull: { "items" : { id: 23 } } }
);

  

MongoDB,从数组中删除对象

标签:highlight   upd   col   cti   pre   _id   mon   date   pytho   

人气教程排行