I have the following document:
{
"_id": ObjectId("5241f1d79b7e7aed05000000"),
"description": {
"nl": "Hallo",
"en": "Hello"
},
"name": "Marc"
}
Now I need to update to update one existing field or add new field to the description. In php I use the update function for Mongo and the following code:
$new_data = array(
'$set' => array(
"description" => array(
"de" => "hallo"
)
)
);
What it does it removes all other fields and just insert the "de" field. I tried replacing $set with $push (which I thought was made for this) but no result also $setOnInsert does not do anything.
How can I solve this problem so that I can either add a new field (if it does not exist) or update if it exist.
Thanks