commit method

Future<CommitResponse> commit (
  1. CommitRequest request,
  2. String session,
  3. {String $fields}
)

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}) {
  var _url;
  var _queryParams = new core.Map<core.String, core.List<core.String>>();
  var _uploadMedia;
  var _uploadOptions;
  var _downloadOptions = commons.DownloadOptions.Metadata;
  var _body;

  if (request != null) {
    _body = convert.json.encode((request).toJson());
  }
  if (session == null) {
    throw new core.ArgumentError("Parameter session is required.");
  }
  if ($fields != null) {
    _queryParams["fields"] = [$fields];
  }

  _url =
      'v1/' + commons.Escaper.ecapeVariableReserved('$session') + ':commit';

  var _response = _requester.request(_url, "POST",
      body: _body,
      queryParams: _queryParams,
      uploadOptions: _uploadOptions,
      uploadMedia: _uploadMedia,
      downloadOptions: _downloadOptions);
  return _response.then((data) => new CommitResponse.fromJson(data));
}