问候,
我有以下 MongoDB 对象:
{
"_id": ObjectId("4d0e28938b012fe28754715a"),
"notifications": {
"0": {
"type": "privateMessage",
"fromUname": "Eamorr2",
"time": 1292773522,
"id": "1lfw70h789u13a1e67pv"
},
"1": {
"type": "privateMessage",
"fromUname": "Eamorr2",
"time": 1292773522,
"id": "iwoidjsoskqp23nlwof"
}
},
"toUname": "Eamorr"
}
我正在尝试删除元素 0,以留给我:
{
"_id": ObjectId("4d0e28938b012fe28754715a"),
"notifications": {
"0": {
"type": "privateMessage",
"fromUname": "Eamorr2",
"time": 1292773522,
"id": "iwoidjsoskqp23nlwof"
}
},
"toUname": "Eamorr"
}
这是我迄今为止尝试过的(在PHP中),但无济于事:
$customerNotifications->update(array('toUname'=>$uname),array('$pull'=>array('notifications'=>$key)));
但它不起作用,我现在完全被卡住了。
非常感谢任何帮助。提前致谢,