UNPKG

@google-cloud/spanner

Version:
801 lines (800 loc) 76.2 kB
import type * as gax from 'google-gax'; import type { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback } from 'google-gax'; import { Transform } from 'stream'; import * as protos from '../../protos/protos'; /** * Cloud Spanner API * * The Cloud Spanner API can be used to manage sessions and execute * transactions on data stored in Cloud Spanner databases. * @class * @memberof v1 */ export declare class SpannerClient { private _terminated; private _opts; private _providedCustomServicePath; private _gaxModule; private _gaxGrpc; private _protos; private _defaults; private _universeDomain; private _servicePath; private _log; auth: gax.GoogleAuth; descriptors: Descriptors; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: { [name: string]: Function; }; pathTemplates: { [name: string]: gax.PathTemplate; }; spannerStub?: Promise<{ [name: string]: Function; }>; /** * Construct an instance of SpannerClient. * * @param {object} [options] - The configuration object. * The options accepted by the constructor are described in detail * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] * @param {string} [options.credentials.private_key] * @param {string} [options.email] - Account email address. Required when * using a .pem or .p12 keyFilename. * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or * .p12 key downloaded from the Google Developers Console. If you provide * a path to a JSON file, the projectId option below is not necessary. * NOTE: .pem and .p12 require you to specify options.email as well. * @param {number} [options.port] - The port on which to connect to * the remote host. * @param {string} [options.projectId] - The project ID from the Google * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you * need to avoid loading the default gRPC version and want to use the fallback * HTTP implementation. Load only fallback version and pass it to the constructor: * ``` * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC * const client = new SpannerClient({fallback: true}, gax); * ``` */ constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback); /** * Initialize the client. * Performs asynchronous operations (such as authentication) and prepares the client. * This function will be called automatically when any class method is called for the * first time, but if you need to initialize it before calling an actual method, * feel free to call initialize() directly. * * You can await on this method if you want to make sure the client is initialized. * * @returns {Promise} A promise that resolves to an authenticated service stub. */ initialize(): Promise<{ [name: string]: Function; }>; /** * The DNS address for this API service. * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath(): string; /** * The DNS address for this API service - same as servicePath. * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint(): string; /** * The DNS address for this API service. * @returns {string} The DNS address for this service. */ get apiEndpoint(): string; get universeDomain(): string; /** * The port for this API service. * @returns {number} The default port for this service. */ static get port(): number; /** * The scopes needed to make gRPC calls for every method defined * in this service. * @returns {string[]} List of default scopes. */ static get scopes(): string[]; getProjectId(): Promise<string>; getProjectId(callback: Callback<string, undefined, undefined>): void; /** * Creates a new session. A session can be used to perform * transactions that read and/or modify data in a Cloud Spanner database. * Sessions are meant to be reused for many consecutive * transactions. * * Sessions can only execute one transaction at a time. To execute * multiple concurrent read-write/write-only transactions, create * multiple sessions. Note that standalone reads and queries use a * transaction internally, and count toward the one transaction * limit. * * Active sessions use additional server resources, so it's a good idea to * delete idle and unneeded sessions. * Aside from explicit deletes, Cloud Spanner can delete sessions when no * operations are sent for more than an hour. If a session is deleted, * requests to it return `NOT_FOUND`. * * Idle sessions can be kept alive by sending a trivial SQL query * periodically, for example, `"SELECT 1"`. * * @param {Object} request * The request object that will be sent. * @param {string} request.database * Required. The database in which the new session is created. * @param {google.spanner.v1.Session} request.session * Required. The session to create. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.Session|Session}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ createSession(request?: protos.google.spanner.v1.ICreateSessionRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | undefined, {} | undefined ]>; createSession(request: protos.google.spanner.v1.ICreateSessionRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | null | undefined, {} | null | undefined>): void; createSession(request: protos.google.spanner.v1.ICreateSessionRequest, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | null | undefined, {} | null | undefined>): void; /** * Creates multiple new sessions. * * This API can be used to initialize a session cache on the clients. * See https://goo.gl/TgSFN2 for best practices on session cache management. * * @param {Object} request * The request object that will be sent. * @param {string} request.database * Required. The database in which the new sessions are created. * @param {google.spanner.v1.Session} request.sessionTemplate * Parameters to apply to each created session. * @param {number} request.sessionCount * Required. The number of sessions to be created in this batch call. * The API can return fewer than the requested number of sessions. If a * specific number of sessions are desired, the client can make additional * calls to `BatchCreateSessions` (adjusting * {@link protos.google.spanner.v1.BatchCreateSessionsRequest.session_count|session_count} * as necessary). * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.BatchCreateSessionsResponse|BatchCreateSessionsResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ batchCreateSessions(request?: protos.google.spanner.v1.IBatchCreateSessionsRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | undefined, {} | undefined ]>; batchCreateSessions(request: protos.google.spanner.v1.IBatchCreateSessionsRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | null | undefined, {} | null | undefined>): void; batchCreateSessions(request: protos.google.spanner.v1.IBatchCreateSessionsRequest, callback: Callback<protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | null | undefined, {} | null | undefined>): void; /** * Gets a session. Returns `NOT_FOUND` if the session doesn't exist. * This is mainly useful for determining whether a session is still * alive. * * @param {Object} request * The request object that will be sent. * @param {string} request.name * Required. The name of the session to retrieve. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.Session|Session}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ getSession(request?: protos.google.spanner.v1.IGetSessionRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | undefined, {} | undefined ]>; getSession(request: protos.google.spanner.v1.IGetSessionRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | null | undefined, {} | null | undefined>): void; getSession(request: protos.google.spanner.v1.IGetSessionRequest, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | null | undefined, {} | null | undefined>): void; /** * Ends a session, releasing server resources associated with it. This * asynchronously triggers the cancellation of any operations that are running * with this session. * * @param {Object} request * The request object that will be sent. * @param {string} request.name * Required. The name of the session to delete. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ deleteSession(request?: protos.google.spanner.v1.IDeleteSessionRequest, options?: CallOptions): Promise<[ protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | undefined, {} | undefined ]>; deleteSession(request: protos.google.spanner.v1.IDeleteSessionRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | null | undefined, {} | null | undefined>): void; deleteSession(request: protos.google.spanner.v1.IDeleteSessionRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | null | undefined, {} | null | undefined>): void; /** * Executes an SQL statement, returning all results in a single reply. This * method can't be used to return a result set larger than 10 MiB; * if the query yields more data than that, the query fails with * a `FAILED_PRECONDITION` error. * * Operations inside read-write transactions might return `ABORTED`. If * this occurs, the application should restart the transaction from * the beginning. See {@link protos.google.spanner.v1.Transaction|Transaction} for more * details. * * Larger result sets can be fetched in streaming fashion by calling * {@link protos.google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} * instead. * * The query string can be SQL or [Graph Query Language * (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro). * * @param {Object} request * The request object that will be sent. * @param {string} request.session * Required. The session in which the SQL query should be performed. * @param {google.spanner.v1.TransactionSelector} request.transaction * The transaction to use. * * For queries, if none is provided, the default is a temporary read-only * transaction with strong concurrency. * * Standard DML statements require a read-write transaction. To protect * against replays, single-use transactions are not supported. The caller * must either supply an existing transaction ID or begin a new transaction. * * Partitioned DML requires an existing Partitioned DML transaction ID. * @param {string} request.sql * Required. The SQL string. * @param {google.protobuf.Struct} request.params * Parameter names and values that bind to placeholders in the SQL string. * * A parameter placeholder consists of the `@` character followed by the * parameter name (for example, `@firstName`). Parameter names must conform * to the naming requirements of identifiers as specified at * https://cloud.google.com/spanner/docs/lexical#identifiers. * * Parameters can appear anywhere that a literal value is expected. The same * parameter name can be used more than once, for example: * * `"WHERE id > @msg_id AND id < @msg_id + 100"` * * It's an error to execute a SQL statement with unbound parameters. * @param {number[]} request.paramTypes * It isn't always possible for Cloud Spanner to infer the right SQL type * from a JSON value. For example, values of type `BYTES` and values * of type `STRING` both appear in * {@link protos.google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings. * * In these cases, you can use `param_types` to specify the exact * SQL type for some or all of the SQL statement parameters. See the * definition of {@link protos.google.spanner.v1.Type|Type} for more information * about SQL types. * @param {Buffer} request.resumeToken * If this request is resuming a previously interrupted SQL statement * execution, `resume_token` should be copied from the last * {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the * interruption. Doing this enables the new SQL statement execution to resume * where the last one left off. The rest of the request parameters must * exactly match the request that yielded this token. * @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode * Used to control the amount of debugging information returned in * {@link protos.google.spanner.v1.ResultSetStats|ResultSetStats}. If * {@link protos.google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is * set, {@link protos.google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only * be set to * {@link protos.google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}. * @param {Buffer} request.partitionToken * If present, results are restricted to the specified partition * previously created using `PartitionQuery`. There must be an exact * match for the values of fields common to this message and the * `PartitionQueryRequest` message used to create this `partition_token`. * @param {number} request.seqno * A per-transaction sequence number used to identify this request. This field * makes each request idempotent such that if the request is received multiple * times, at most one succeeds. * * The sequence number must be monotonically increasing within the * transaction. If a request arrives for the first time with an out-of-order * sequence number, the transaction can be aborted. Replays of previously * handled requests yield the same response as the first execution. * * Required for DML statements. Ignored for queries. * @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions * Query optimizer configuration to use for the given query. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. * @param {google.spanner.v1.DirectedReadOptions} request.directedReadOptions * Directed read options for this request. * @param {boolean} request.dataBoostEnabled * If this is for a partitioned query and this field is set to `true`, the * request is executed with Spanner Data Boost independent compute resources. * * If the field is set to `true` but the request doesn't set * `partition_token`, the API returns an `INVALID_ARGUMENT` error. * @param {boolean} [request.lastStatement] * Optional. If set to `true`, this statement marks the end of the * transaction. After this statement executes, you must commit or abort the * transaction. Attempts to execute any other requests against this * transaction (including reads and queries) are rejected. * * For DML statements, setting this option might cause some error reporting to * be deferred until commit time (for example, validation of unique * constraints). Given this, successful execution of a DML statement shouldn't * be assumed until a subsequent `Commit` call completes successfully. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.ResultSet|ResultSet}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ executeSql(request?: protos.google.spanner.v1.IExecuteSqlRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | undefined, {} | undefined ]>; executeSql(request: protos.google.spanner.v1.IExecuteSqlRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | null | undefined, {} | null | undefined>): void; executeSql(request: protos.google.spanner.v1.IExecuteSqlRequest, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | null | undefined, {} | null | undefined>): void; /** * Executes a batch of SQL DML statements. This method allows many statements * to be run with lower latency than submitting them sequentially with * {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}. * * Statements are executed in sequential order. A request can succeed even if * a statement fails. The * {@link protos.google.spanner.v1.ExecuteBatchDmlResponse.status|ExecuteBatchDmlResponse.status} * field in the response provides information about the statement that failed. * Clients must inspect this field to determine whether an error occurred. * * Execution stops after the first failed statement; the remaining statements * are not executed. * * @param {Object} request * The request object that will be sent. * @param {string} request.session * Required. The session in which the DML statements should be performed. * @param {google.spanner.v1.TransactionSelector} request.transaction * Required. The transaction to use. Must be a read-write transaction. * * To protect against replays, single-use transactions are not supported. The * caller must either supply an existing transaction ID or begin a new * transaction. * @param {number[]} request.statements * Required. The list of statements to execute in this batch. Statements are * executed serially, such that the effects of statement `i` are visible to * statement `i+1`. Each statement must be a DML statement. Execution stops at * the first failed statement; the remaining statements are not executed. * * Callers must provide at least one statement. * @param {number} request.seqno * Required. A per-transaction sequence number used to identify this request. * This field makes each request idempotent such that if the request is * received multiple times, at most one succeeds. * * The sequence number must be monotonically increasing within the * transaction. If a request arrives for the first time with an out-of-order * sequence number, the transaction might be aborted. Replays of previously * handled requests yield the same response as the first execution. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. * @param {boolean} [request.lastStatements] * Optional. If set to `true`, this request marks the end of the transaction. * After these statements execute, you must commit or abort the transaction. * Attempts to execute any other requests against this transaction * (including reads and queries) are rejected. * * Setting this option might cause some error reporting to be deferred until * commit time (for example, validation of unique constraints). Given this, * successful execution of statements shouldn't be assumed until a subsequent * `Commit` call completes successfully. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.ExecuteBatchDmlResponse|ExecuteBatchDmlResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ executeBatchDml(request?: protos.google.spanner.v1.IExecuteBatchDmlRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | undefined, {} | undefined ]>; executeBatchDml(request: protos.google.spanner.v1.IExecuteBatchDmlRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | null | undefined, {} | null | undefined>): void; executeBatchDml(request: protos.google.spanner.v1.IExecuteBatchDmlRequest, callback: Callback<protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | null | undefined, {} | null | undefined>): void; /** * Reads rows from the database using key lookups and scans, as a * simple key/value style alternative to * {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}. This method can't be * used to return a result set larger than 10 MiB; if the read matches more * data than that, the read fails with a `FAILED_PRECONDITION` * error. * * Reads inside read-write transactions might return `ABORTED`. If * this occurs, the application should restart the transaction from * the beginning. See {@link protos.google.spanner.v1.Transaction|Transaction} for more * details. * * Larger result sets can be yielded in streaming fashion by calling * {@link protos.google.spanner.v1.Spanner.StreamingRead|StreamingRead} instead. * * @param {Object} request * The request object that will be sent. * @param {string} request.session * Required. The session in which the read should be performed. * @param {google.spanner.v1.TransactionSelector} request.transaction * The transaction to use. If none is provided, the default is a * temporary read-only transaction with strong concurrency. * @param {string} request.table * Required. The name of the table in the database to be read. * @param {string} request.index * If non-empty, the name of an index on * {@link protos.google.spanner.v1.ReadRequest.table|table}. This index is used instead of * the table primary key when interpreting * {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} and sorting result rows. * See {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} for further * information. * @param {string[]} request.columns * Required. The columns of {@link protos.google.spanner.v1.ReadRequest.table|table} to be * returned for each row matching this request. * @param {google.spanner.v1.KeySet} request.keySet * Required. `key_set` identifies the rows to be yielded. `key_set` names the * primary keys of the rows in {@link protos.google.spanner.v1.ReadRequest.table|table} to * be yielded, unless {@link protos.google.spanner.v1.ReadRequest.index|index} is present. * If {@link protos.google.spanner.v1.ReadRequest.index|index} is present, then * {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} instead names index keys * in {@link protos.google.spanner.v1.ReadRequest.index|index}. * * If the {@link protos.google.spanner.v1.ReadRequest.partition_token|partition_token} * field is empty, rows are yielded in table primary key order (if * {@link protos.google.spanner.v1.ReadRequest.index|index} is empty) or index key order * (if {@link protos.google.spanner.v1.ReadRequest.index|index} is non-empty). If the * {@link protos.google.spanner.v1.ReadRequest.partition_token|partition_token} field * isn't empty, rows are yielded in an unspecified order. * * It isn't an error for the `key_set` to name rows that don't * exist in the database. Read yields nothing for nonexistent rows. * @param {number} request.limit * If greater than zero, only the first `limit` rows are yielded. If `limit` * is zero, the default is no limit. A limit can't be specified if * `partition_token` is set. * @param {Buffer} request.resumeToken * If this request is resuming a previously interrupted read, * `resume_token` should be copied from the last * {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the * interruption. Doing this enables the new read to resume where the last read * left off. The rest of the request parameters must exactly match the request * that yielded this token. * @param {Buffer} request.partitionToken * If present, results are restricted to the specified partition * previously created using `PartitionRead`. There must be an exact * match for the values of fields common to this message and the * PartitionReadRequest message used to create this partition_token. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. * @param {google.spanner.v1.DirectedReadOptions} request.directedReadOptions * Directed read options for this request. * @param {boolean} request.dataBoostEnabled * If this is for a partitioned read and this field is set to `true`, the * request is executed with Spanner Data Boost independent compute resources. * * If the field is set to `true` but the request doesn't set * `partition_token`, the API returns an `INVALID_ARGUMENT` error. * @param {google.spanner.v1.ReadRequest.OrderBy} [request.orderBy] * Optional. Order for the returned rows. * * By default, Spanner returns result rows in primary key order except for * PartitionRead requests. For applications that don't require rows to be * returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting * `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval, * resulting in lower latencies in certain cases (for example, bulk point * lookups). * @param {google.spanner.v1.ReadRequest.LockHint} [request.lockHint] * Optional. Lock Hint for the request, it can only be used with read-write * transactions. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.ResultSet|ResultSet}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ read(request?: protos.google.spanner.v1.IReadRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | undefined, {} | undefined ]>; read(request: protos.google.spanner.v1.IReadRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | null | undefined, {} | null | undefined>): void; read(request: protos.google.spanner.v1.IReadRequest, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | null | undefined, {} | null | undefined>): void; /** * Begins a new transaction. This step can often be skipped: * {@link protos.google.spanner.v1.Spanner.Read|Read}, * {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql} and * {@link protos.google.spanner.v1.Spanner.Commit|Commit} can begin a new transaction as a * side-effect. * * @param {Object} request * The request object that will be sent. * @param {string} request.session * Required. The session in which the transaction runs. * @param {google.spanner.v1.TransactionOptions} request.options * Required. Options for the new transaction. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. * Priority is ignored for this request. Setting the priority in this * `request_options` struct doesn't do anything. To set the priority for a * transaction, set it on the reads and writes that are part of this * transaction instead. * @param {google.spanner.v1.Mutation} [request.mutationKey] * Optional. Required for read-write transactions on a multiplexed session * that commit mutations but don't perform any reads or queries. You must * randomly select one of the mutations from the mutation set and send it as a * part of this request. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.Transaction|Transaction}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ beginTransaction(request?: protos.google.spanner.v1.IBeginTransactionRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | undefined, {} | undefined ]>; beginTransaction(request: protos.google.spanner.v1.IBeginTransactionRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void; beginTransaction(request: protos.google.spanner.v1.IBeginTransactionRequest, callback: Callback<protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void; /** * 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 retry * the transaction from the beginning, reusing 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. * * @param {Object} request * The request object that will be sent. * @param {string} request.session * Required. The session in which the transaction to be committed is running. * @param {Buffer} request.transactionId * Commit a previously-started transaction. * @param {google.spanner.v1.TransactionOptions} request.singleUseTransaction * Execute mutations in a temporary transaction. Note that unlike * commit of a previously-started transaction, commit with a * temporary transaction is non-idempotent. That is, if the * `CommitRequest` is sent to Cloud Spanner more than once (for * instance, due to retries in the application, or in the * transport library), it's possible that the mutations are * executed more than once. If this is undesirable, use * {@link protos.google.spanner.v1.Spanner.BeginTransaction|BeginTransaction} and * {@link protos.google.spanner.v1.Spanner.Commit|Commit} instead. * @param {number[]} request.mutations * The mutations to be executed when this transaction commits. All * mutations are applied atomically, in the order they appear in * this list. * @param {boolean} request.returnCommitStats * If `true`, then statistics related to the transaction is included in * the {@link protos.google.spanner.v1.CommitResponse.commit_stats|CommitResponse}. * Default value is `false`. * @param {google.protobuf.Duration} [request.maxCommitDelay] * Optional. The amount of latency this request is configured to incur in * order to improve throughput. If this field isn't set, Spanner assumes * requests are relatively latency sensitive and automatically determines an * appropriate delay time. You can specify a commit delay value between 0 and * 500 ms. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. * @param {google.spanner.v1.MultiplexedSessionPrecommitToken} [request.precommitToken] * Optional. If the read-write transaction was executed on a multiplexed * session, then you must include the precommit token with the highest * sequence number received in this transaction attempt. Failing to do so * results in a `FailedPrecondition` error. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.CommitResponse|CommitResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ commit(request?: protos.google.spanner.v1.ICommitRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | undefined, {} | undefined ]>; commit(request: protos.google.spanner.v1.ICommitRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | null | undefined, {} | null | undefined>): void; commit(request: protos.google.spanner.v1.ICommitRequest, callback: Callback<protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | null | undefined, {} | null | undefined>): void; /** * Rolls back a transaction, releasing any locks it holds. It's a good * idea to call this for any transaction that includes one or more * {@link protos.google.spanner.v1.Spanner.Read|Read} or * {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql} requests and ultimately * decides not to commit. * * `Rollback` returns `OK` if it successfully aborts the transaction, the * transaction was already aborted, or the transaction isn't * found. `Rollback` never returns `ABORTED`. * * @param {Object} request * The request object that will be sent. * @param {string} request.session * Required. The session in which the transaction to roll back is running. * @param {Buffer} request.transactionId * Required. The transaction to roll back. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ rollback(request?: protos.google.spanner.v1.IRollbackRequest, options?: CallOptions): Promise<[ protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | undefined, {} | undefined ]>; rollback(request: protos.google.spanner.v1.IRollbackRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void; rollback(request: protos.google.spanner.v1.IRollbackRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void; /** * Creates a set of partition tokens that can be used to execute a query * operation in parallel. Each of the returned partition tokens can be used * by {@link protos.google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} to * specify a subset of the query result to read. The same session and * read-only transaction must be used by the `PartitionQueryRequest` used to * create the partition tokens and the `ExecuteSqlRequests` that use the * partition tokens. * * Partition tokens become invalid when the session used to create them * is deleted, is idle for too long, begins a new transaction, or becomes too * old. When any of these happen, it isn't possible to resume the query, and * the whole operation must be restarted from the beginning. * * @param {Object} request * The request object that will be sent. * @param {string} request.session * Required. The session used to create the partitions. * @param {google.spanner.v1.TransactionSelector} request.transaction * Read-only snapshot transactions are supported, read and write and * single-use transactions are not. * @param {string} request.sql * Required. The query request to generate partitions for. The request fails * if the query isn't root partitionable. For a query to be root * partitionable, it needs to satisfy a few conditions. For example, if the * query execution plan contains a distributed union operator, then it must be * the first operator in the plan. For more information about other * conditions, see [Read data in * parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel). * * The query request must not contain DML commands, such as `INSERT`, * `UPDATE`, or `DELETE`. Use * {@link protos.google.spanner.v1.Spanner.ExecuteStreamingSql|`ExecuteStreamingSql`} with * a `PartitionedDml` transaction for large, partition-friendly DML * operations. * @param {google.protobuf.Struct} request.params * Parameter names and values that bind to placeholders in the SQL string. * * A parameter placeholder consists of the `@` character followed by the * parameter name (for example, `@firstName`). Parameter names can contain * letters, numbers, and underscores. * * Parameters can appear anywhere that a literal value is expected. The same * parameter name can be used more than once, for example: * * `"WHERE id > @msg_id AND id < @msg_id + 100"` * * It's an error to execute a SQL statement with unbound parameters. * @param {number[]} request.paramTypes * It isn't always possible for Cloud Spanner to infer the right SQL type * from a JSON value. For example, values of type `BYTES` and values * of type `STRING` both appear in * {@link protos.google.spanner.v1.PartitionQueryRequest.params|params} as JSON strings. * * In these cases, `param_types` can be used to specify the exact * SQL type for some or all of the SQL query parameters. See the * definition of {@link protos.google.spanner.v1.Type|Type} for more information * about SQL types. * @param {google.spanner.v1.PartitionOptions} request.partitionOptions * Additional options that affect how many partitions are created. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.PartitionResponse|PartitionResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */ partitionQuery(request?: protos.google.spanner.v1.IPartitionQueryRequest, options?: CallOptions): Promise<[ protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | undefined, {} | undefined ]>; partitionQuery(request: protos.google.spanner.v1.IPartitionQueryRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | null | undefined, {} | null | undefined>): void; partitionQuery(request: protos.google.spanner.v1.IPartitionQueryRequest, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | null | undefined, {} | null | undefined>): void; /** * Creates a set of partition tokens that can be used to execute a read * operation in parallel. Each of the returned partition tokens can be used * by {@link protos.google.spanner.v1.Spanner.StreamingRead|StreamingRead} to specify a * subset of the read result to read. The same session and read-only * transaction must be used by the `PartitionReadRequest` used to create the * partition tokens and the `ReadRequests` that use the partition tokens. * There are no ordering guarantees on rows returned among the returned * partition tokens, or even within each individual `StreamingRead` call * issued with a `partition_token`. * * Partition tokens become invalid when the session used to create them * is deleted, is idle for too long, begins a new transaction, or becomes too * old. When any of these happen, it isn't possible to resume the read, and * the whole operation must be restarted from the beginning. * * @param {Object} request * The request object that will be sent. * @param {string} request.session * Required. The session used to create the partitions. * @param {google.spanner.v1.TransactionSelector} request.transaction * Read only snapshot transactions are supported, read/write and single use * transactions are not. * @param {string} request.table * Required. The name of the table in the database to be read. * @param {string} request.index * If non-empty, the name of an index on * {@link protos.google.spanner.v1.PartitionReadRequest.table|table}. This index is used * instead of the table primary key when interpreting * {@link protos.google.spanner.v1.PartitionReadRequest.key_set|key_set} and sorting * result rows. See {@link protos.google.spanner.v1.PartitionReadRequest.key_set|key_set} * for further information. * @param {string[]} request.columns * The columns of {@link protos.google.spanner.v1.PartitionReadRequest.table|table} to be * returned for each row matching this request. * @param {google.spanner.v1.KeySet} request.keySet * Required. `key_set` identifies the rows to be yielded. `key_set` names the * primary keys of the rows in * {@link protos.google.spanner.v1.PartitionReadRequest.table|table} to be yielded, unless * {@link protos.google.spanner.v1.PartitionReadRequest.index|index} is present. If * {@link protos.google.spanner.v1.PartitionReadRequest.index|index} is present, then * {@link protos.google.spanner.v1.PartitionReadRequest.key_set|key_set} instead names * index keys in {@link protos.google.spanner.v1.PartitionReadRequest.index|index}. * * It isn't an error for the `key_set` to name rows that don't * exist in the database. Read yields nothing for nonexistent rows. * @param {google.spanner.v1.PartitionOptions} request.partitionOptions * Additional options that affect how many partitions are created. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.spanner.v1.PartitionResponse|PartitionResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. */