MongoDB, remove object from array

前端 未结 7 2186
余生分开走
余生分开走 2020-11-22 16:19

Doc:

{
   _id: 5150a1199fac0e6910000002,
   name: \'some name,
   items: [{
      id: 23,
      name: \'item name 23\'
   },{
      id: 24,
      name: \'ite         


        
7条回答
  •  盖世英雄少女心
    2020-11-22 17:15

    Kishore Diyyana:

    If you want to remove all elements including key of the element attributes list. Here is the example of mongoDB unset operator:

    db.UM_PREAUTH_CASE.update( { 'Id' : 123}, { $unset: { dataElements: ""} } )

    JSON Look like this:

    { "Id":123,"dataElements" : [ { "createdBy" : "Kishore Babu Diyyana", "createdByUserId" : 2020 }, { "createdBy" : "Diyyana Kishore", "createdByUserId" : 2021 } ] }

提交回复
热议问题