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

upsert() public method

No service requests are run when this method is called. Use {@see \Google\Cloud\Datastore\Transaction::commit()} to commit changes. Upsert will create a record if one does not already exist, or overwrite existing record if one already exists. Example: $key = $datastore->key('Person', 'Bob'); $entity = $datastore->entity($key, ['firstName' => 'Bob']); $transaction->upsert($entity); $transaction->commit();
public upsert ( Entity $entity ) : Transaction
$entity Entity The entity to upsert.
return Transaction
    public function upsert(Entity $entity)
    {
        return $this->upsertBatch([$entity]);
    }