4
我有以下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"
}
這裏就是我試過SOFAR(在PHP),無濟於事:
$customerNotifications->update(array('toUname'=>$uname),array('$pull'=>array('notifications'=>$key)));
但它不工作,我現在完全卡住了。
任何幫助非常感謝。在此先感謝,
如果您確定這是通知數組的正確索引,該怎麼辦?那麼你怎麼能確定陣列物品? – 2012-12-19 18:30:35