Google\Cloud\Datastore\DatastoreClient::upsert PHP Method

upsert() public method

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);
public upsert ( Entity $entity, array $options = [] ) : string
$entity Entity The entity to be upserted.
$options array [optional] Configuration Options.
return string The entity version.
    public function upsert(Entity $entity, array $options = [])
    {
        $res = $this->upsertBatch([$entity], $options);
        return $this->parseSingleMutationResult($res);
    }