public function updateMetadata($user, $imageIdentifier, array $metadata)
{
try {
// Fetch existing metadata and merge with the incoming data
$existing = $this->getMetadata($user, $imageIdentifier);
$updatedMetadata = array_merge($existing, $metadata);
$this->getImageCollection()->update(['user' => $user, 'imageIdentifier' => $imageIdentifier], ['$set' => ['updated' => time(), 'metadata' => $updatedMetadata]], ['multiple' => false]);
} catch (MongoException $e) {
throw new DatabaseException('Unable to update meta data', 500, $e);
}
return true;
}