Upsert will create a record if one does not already exist, or overwrite
existing record if one already exists.
Please note that upserting a record in Cloud Datastore will replace the
existing record, if one exists. Adding, editing or removing a single
property is only possible by first retrieving the entire entity in its
existing state.
Upsert by this method is non-transactional. If you need transaction
support, use {@see \Google\Cloud\Datastore\Transaction::upsert()}.
Example:
$key = $datastore->key('Person', 'Bob');
$entity = $datastore->entity($key, ['firstName' => 'Bob']);
$datastore->upsert($entity);