如何删除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: +1786543589455pull
呼唤远方
茅侃侃
随时随地看视频慕课网APP
相关分类