如何删除MongoDB中的数组元素?
contact: { phone: [ { number: "+1786543589455", place: "New Jersey", createdAt: "" } { number: "+1986543589455", place: "Houston", createdAt: "" } ]}
_id
+1786543589455
contact: { phone: [ { number: "+1986543589455", place: "Houston", createdAt: "" } ]}
collection.update( { _id: id, 'contact.phone': '+1786543589455' }, { $unset: { 'contact.phone.$.number': '+1786543589455'} });
number: +1786543589455
pull
茅侃侃
相关分类