How to remove array element in mongodb?

后端 未结 6 1557
情深已故
情深已故 2020-11-22 07:10

Here is array structure

contact: {
    phone: [
        {
            number: \"+1786543589455\",
            place: \"New Jersey\",
            createdAt: \         


        
6条回答
  •  生来不讨喜
    2020-11-22 07:39

    To remove all array elements irrespective of any given id, use this:

    collection.update(
      { },
      { $pull: { 'contact.phone': { number: '+1786543589455' } } }
    );
    

提交回复
热议问题