I'm trying to update the "coordinates" property in the Mongo document with new events. ie. Merge the "coordinates" array (contains array of events) with new array of events.
What I have so far :
$update = array('$push' => array("coordinates" => $events));
/** @var \MongoCollection $collection */
$collection = $db->$collectionName;
$return = $collection->update($conditions, $update, $options);
if ($return === false) {
throw new \ErrorException('Unable to update collection');
}
This works without throwing any error but not as intended. The above query appends the $events array to the "coordinates" array as an array.
Confusing? Maybe the image below will explain better..
Maybe someone can help me figure where I'm going wrong!

array_merge()and then rewrite the"coordinates"with $set. But this doesn't seem like the best solution to me.