I have this structure:
{
"_id": NumberInt(101),
"link_id": {
"125": {
"thumb_position": NumberInt(1),
"last_scan": NumberInt(1234563645),
"row_numb": NumberInt(301),
"clicks": NumberInt(120)
},
"126": {
"thumb_position": NumberInt(2),
"last_scan": NumberInt(-2147483648),
"row_numb": NumberInt(1301),
"clicks": NumberInt(199)
},
{
...
}
}
}
and I want to update the document with new linkids and get:
{
"_id": NumberInt(101),
"link_id": {
"125": {
"thumb_position": NumberInt(1),
"last_scan": NumberInt(1234563645),
"row_numb": NumberInt(301),
"clicks": NumberInt(120)
},
"126": {
"thumb_position": NumberInt(2),
"last_scan": NumberInt(-2147483648),
"row_numb": NumberInt(1301),
"clicks": NumberInt(199)
},
"127": {
"thumb_position": NumberInt(1),
"last_scan": NumberInt(-2147483628),
"row_numb": NumberInt(1304),
"clicks": NumberInt(195)
}
}
I have tried in php:
$value = array (
'130' =>
array (
'thumb_position' => 1,
'last_scan' => 1234563640,
'row_numb' => 300,
'clicks' => 120,
));
$update_status = $collection->update( array('_id'=>intval(101)), array('$set' => array('link_id' => $value)) , array("upsert"=>true ,"multiple"=> true , "safe"=> true) );
but this is only overwriting the link_ids with this 130.
the embedded aproach... since this is not an array, but objects, any idea on how to solve this? Thx a lot.
code{ "_id": NumberInt(100), "link_id": { "129": { "thumb_position": NumberInt(1), "last_scan": NumberInt(1234563649), "row_numb": NumberInt(309), "clicks": NumberInt(129) }, "130": null } } the value was:code$value_i = array ( 'thumb_position' => 1, 'last_scan' => 1234563641, 'row_numb' => 301, 'clicks' => 121, ); so it added a null entrance. Guess the way is around. Thx again.code$update_status = $collection->update( array('_id'=>intval(100), 'link_id'=> "133"), array('$set' => array('link_id.133' => null)) , array("upsert"=>true ,"multiple"=> true , "safe"=> true) ); ?