0
    {
       "_id":5150a1199fac0e6910000002,
       "name":"some name",
       "items":[
          {
             "id":23,
             "name":"item name 23",
             "childItems":[
                {
                   "id":233,
                   "name":"item 233"
                },
                {
                   "id":234,
                   "name":"item 234"
                }
             ]
          },
          {
             "id":24,
             "name":"item name 24",
             "childItems":[]
          }
       ]
    }

I'm trying to update the 'document in array' of array. I have got the query to work on its parent (the stakeholder array) with the positional $ operator, using the answer to this question I asked previously. So my query looks like this.....

this.model.findOneAndUpdate( { items: { id: '23' } }, { $pull: { items: { childItems: { id: '223' } } } },).exec();

1 Answers1

0

Through some step, finally i can solved this problem with query

await this.model
            .update(
              { 'items.id': 'id' },
              { $pull: { 'items.$[element].childItems': { id: 'id' } } },
              { arrayFilters: [{ 'element._id': 'id' }], multi: true },
            )
            .exec();

Thanks to Cuong Le Ngoc