commit method
Commits a transaction.
The request includes the mutations to be applied to rows in the database.
Commit
might return an ABORTED
error. This can occur at any time;
commonly, the cause is conflicts with concurrent transactions. However, it
can also happen for a variety of other reasons. If Commit
returns
ABORTED
, the caller should re-attempt the transaction from the
beginning, re-using the same session. On very rare occasions, Commit
might return UNKNOWN
. This can happen, for example, if the client job
experiences a 1+ hour networking failure. At that point, Cloud Spanner has
lost track of the transaction outcome and we recommend that you perform
another read from the database to see the state of things as they are now.
request
- The metadata request object.
Request parameters:
session
- Required. The session in which the transaction to be committed
is running.
Value must have pattern
^projects/\[^/\]+/instances/\[^/\]+/databases/\[^/\]+/sessions/\[^/\]+$
.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a CommitResponse.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client
completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<CommitResponse> commit(
CommitRequest request,
core.String session, {
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v1/' + core.Uri.encodeFull('$session') + ':commit';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return CommitResponse.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}