Mongoose findOneAndUpdate: update an object in an array of objects

前端 未结 2 1053
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 11:45

I have the exact same issue as described in this thread (hence the similar title): Mongoose findOneAndUpdate -- updating an object inside an array of objects

Given t

2条回答
  •  心在旅途
    2021-01-07 12:31

    I think you mismatched id and user field

    Try to change id with user

    SavedFoods.findOneAndUpdate(
        {
          user: userId,
          'list.id': 0
        }
    )
    

提交回复
热议问题