MongoDB, remove object from array

前端 未结 7 2090
余生分开走
余生分开走 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:02

    Use $pull to remove the data

    return this.mobiledashboardModel
    .update({"_id": args.dashboardId}, { $pull: {"viewData": { "_id": widgetId}}})
    .exec()
    .then(dashboardDoc => {
         return {
            result: dashboardDoc
         }
    });
    

提交回复
热议问题