我的表UserCollection上有这样的文件:
{
"FirstName": "Mohammad",
"LastName": "Waheed",
}
我想向它添加另一个数组对象,我该怎么做。?
"PhoneNumbers":[ //this object is not present in the table
{
"number": NumberInt(8332045764)
},
{
"number": NumberInt(1234567890)
}
]
我的预期结果是这样的:
{
"FirstName": "Mohammad",
"LastName": "Waheed",
"PhoneNumbers":[
{
"number": NumberInt(8332045764)
},
{
"number": NumberInt(1234567890) //when i call this method again it should store like this
}
]
}
这就是我尝试过的: 1.只获取那条记录 2. $number有电话号码的数据
return $db->update(array('$set' => array("PhoneNumbers.$.number" => $number)));