How to remove array element in mongodb?

Try the following query:

  { _id: id },
  { $pull: { '': { number: '+1786543589455' } } }

It will find document with the given _id and remove the phone +1786543589455 from its array.

You can use $unset to unset the value in the array (set it to null), but not to remove it completely.

Leave a Comment