以下是这样的内容mongodb
:
{
"_id": 74924,
"bangs": {
"436": {
"join_time": 1345624851,
"status": 1,
"scores": 0
},
"446": {
"join_time": 1355727257,
"status": 1,
"scores": 0
}
},
"_id": 74926,
"bangs": {
"436": {
"join_time": 1345624851,
"status": 1,
"scores": 0
},
"446": {
"join_time": 1355727257,
"status": 1,
"scores": 0
}
}
}
我想删除:
"436": {
"join_time": 1345624851,
"status": 1,
"scores": 0
},
where _id=74924
结果将是:
{
"_id": 74924,
"bangs": {
"446": {
"join_time": 1355727257,
"status": 1,
"scores": 0
}
},
"_id": 74926,
"bangs": {
"436": {
"join_time": 1345624851,
"status": 1,
"scores": 0
},
"446": {
"join_time": 1355727257,
"status": 1,
"scores": 0
}
}
}
我写了这样的代码:
$mongo->users->users->update(array('_id'=>74924), array('$pull'=>array('bangs'=>436)));
但是记录没有删除
我该如何编写代码?
提前致谢!