这是数组结构
contact: {
    phone: [
        {
            number: "+1786543589455",
            place: "New Jersey",
            createdAt: ""
        }
        {
            number: "+1986543589455",
            place: "Houston",
            createdAt: ""
        }
    ]
}
在这里,我只知道mongo id(_id)和电话号码(+1786543589455),并且需要从文档中删除整个对应的数组元素。即电话阵列中的零索引元素与电话号码匹配,需要删除相应的阵列元素。
contact: {
    phone: [
        {
            number: "+1986543589455",
            place: "Houston",
            createdAt: ""
        }
    ]
}
我尝试了以下更新方法
collection.update(
    { _id: id, 'contact.phone': '+1786543589455' },
    { $unset: { 'contact.phone.$.number': '+1786543589455'} }
);
但是它number:  +1786543589455从内部数组对象中删除,而不是从电话数组中的零索引元素中删除   。尝试pull也没有成功。
如何在mongodb中删除数组元素?
{ $pull: { 'contact.phone.$': { 'contact.phone.$.number': '+1786543589455' } } }和{ $pull: { 'contact.phone': { 'contact.phone.$.number': '+1786543589455' } } }没有取得成功。这里不了解位置操作员的工作吗?