Remove sub-document from Mongo with mongoose

后端 未结 6 535
情歌与酒
情歌与酒 2020-12-16 01:12

I am trying to remove an item from a collection that is stored in a mongoose document. My document looks like this:

{
  \"__v\": 3,
  \"_id\": \"5221040475f         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 01:38

    You want inventory.items.pull(req.params.itemSku), followed by an inventory.save call. .remove is for top-level documents

提交回复
热议问题