【发布时间】:2014-05-19 06:45:54
【问题描述】:
我在 mongodb 中有一个类似这样的文档
{
"_id": ObjectId("5378da275ad972a811c119fb"),
"name": "test test",
"fname": "test",
"lname": "test",
"phone": "13254355554",
"user": "525518965ad972636d7aa0ae",
}
我想为“employee_id”插入一个新字段,所以结果应该是这样的。
{
"_id": ObjectId("5378da275ad972a811c119fb"),
"name": "test test",
"fname": "test",
"lname": "test",
"employee_id": "09872",
"phone": "13254355554",
"user": "525518965ad972636d7aa0ae",
}
我使用了 $push 和 $addToSet 但结果变成了一个类似的数组
"employee_id": {
"0": "09872",
}
【问题讨论】:
标签: php mongodb mongodb-query database