Calling this method will end the operation (and close the transaction,
if one is specified).
public commit ( array $mutations, array $options = [] ) : array | ||
$mutations | array | [Mutation[]](https://cloud.google.com/datastore/docs/reference/rest/v1/projects/commit#Mutation). |
$options | array | [optional] { Configuration Options @type string $transaction The transaction ID, if the query should be run in a transaction. } |
return | array | [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body) |
/** * Delete multiple entities * * Deletion by this method is non-transactional. If you need transaction * support, use {@see Google\Cloud\Datastore\Transaction::deleteBatch()}. * * Example: * ``` * $keys = [ * $datastore->key('Person', 'Bob'), * $datastore->key('Person', 'John') * ]; * * $datastore->deleteBatch($keys); * ``` * * @param Key[] $keys The identifiers to delete. * @param array $options [optional] { * Configuration options * * @type string $baseVersion Provides concurrency control. The version * of the entity that this mutation is being applied to. If this * does not match the current version on the server, the mutation * conflicts. * } * @return array [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body) */ public function deleteBatch(array $keys, array $options = []) { $options += ['baseVersion' => null]; $mutations = []; foreach ($keys as $key) { $mutations[] = $this->operation->mutation('delete', $key, Key::class, $options['baseVersion']); } return $this->operation->commit($mutations, $options); }
/** * Commit all mutations * * Calling this method will end the operation (and close the transaction, * if one is specified). * * Example: * ``` * $transaction->commit() * ``` * * @param array $options [optional] Configuration Options. * @return array [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body) */ public function commit(array $options = []) { $options['transaction'] = $this->transactionId; return $this->operation->commit($options); }
/** * Delete multiple entities * * Deletion by this method is non-transactional. If you need transaction * support, use {@see Google\Cloud\Datastore\Transaction::deleteBatch()}. * * Example: * ``` * $keys = [ * $datastore->key('Person', 'Bob'), * $datastore->key('Person', 'John') * ]; * * $datastore->deleteBatch($keys); * ``` * * @param Key[] $keys The identifiers to delete. * @param array $options [optional] { * Configuration options * * @type string $baseVersion Provides concurrency control. The version * of the entity that this mutation is being applied to. If this * does not match the current version on the server, the mutation * conflicts. * } * @return array [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body) */ public function deleteBatch(array $keys, array $options = []) { $options += ['baseVersion' => null]; $this->operation->mutate('delete', $keys, Key::class, $options['baseVersion']); return $this->operation->commit($options); }