Cloud Spanner API
The Cloud Spanner API can be used to manage sessions and execute transactions on data stored in Cloud Spanner databases. v1
Package
@google-cloud/spannerConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of SpannerClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of |
Properties
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
pathTemplates
pathTemplates: {
[name: string]: gax.PathTemplate;
};
port
static get port(): number;
The port for this API service.
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
spannerStub
spannerStub?: Promise<{
[name: string]: Function;
}>;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
batchCreateSessions(request, options)
batchCreateSessions(request?: protos.google.spanner.v1.IBatchCreateSessionsRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.IBatchCreateSessionsResponse,
protos.google.spanner.v1.IBatchCreateSessionsRequest | undefined,
{} | undefined
]>;
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.
Parameters | |
---|---|
Name | Description |
request |
IBatchCreateSessionsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.IBatchCreateSessionsResponse,
protos.google.spanner.v1.IBatchCreateSessionsRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
batchCreateSessions(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IBatchCreateSessionsRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
batchCreateSessions(request, callback)
batchCreateSessions(request: protos.google.spanner.v1.IBatchCreateSessionsRequest, callback: Callback<protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IBatchCreateSessionsRequest
|
callback |
Callback<protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
beginTransaction(request, options)
beginTransaction(request?: protos.google.spanner.v1.IBeginTransactionRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.ITransaction,
protos.google.spanner.v1.IBeginTransactionRequest | undefined,
{} | undefined
]>;
Begins a new transaction. This step can often be skipped: , and can begin a new transaction as a side-effect.
Parameters | |
---|---|
Name | Description |
request |
IBeginTransactionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.ITransaction,
protos.google.spanner.v1.IBeginTransactionRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
beginTransaction(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IBeginTransactionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
beginTransaction(request, callback)
beginTransaction(request: protos.google.spanner.v1.IBeginTransactionRequest, callback: Callback<protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IBeginTransactionRequest
|
callback |
Callback<protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns | |
---|---|
Type | Description |
Promise<void> | {Promise} A promise that resolves when the client is closed. |
commit(request, options)
commit(request?: protos.google.spanner.v1.ICommitRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.ICommitResponse,
protos.google.spanner.v1.ICommitRequest | undefined,
{} | undefined
]>;
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.
Parameters | |
---|---|
Name | Description |
request |
ICommitRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.ICommitResponse,
protos.google.spanner.v1.ICommitRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
commit(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
ICommitRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
commit(request, callback)
commit(request: protos.google.spanner.v1.ICommitRequest, callback: Callback<protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
ICommitRequest
|
callback |
Callback<protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
createSession(request, options)
createSession(request?: protos.google.spanner.v1.ICreateSessionRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.ISession,
protos.google.spanner.v1.ICreateSessionRequest | undefined,
{} | undefined
]>;
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 is a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner may delete sessions for which 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, e.g., "SELECT 1"
.
Parameters | |
---|---|
Name | Description |
request |
ICreateSessionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.ISession,
protos.google.spanner.v1.ICreateSessionRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
createSession(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
ICreateSessionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
createSession(request, callback)
createSession(request: protos.google.spanner.v1.ICreateSessionRequest, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
ICreateSessionRequest
|
callback |
Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
databasePath(project, instance, database)
databasePath(project: string, instance: string, database: string): string;
Return a fully-qualified database resource name string.
Parameters | |
---|---|
Name | Description |
project |
string
|
instance |
string
|
database |
string
|
Returns | |
---|---|
Type | Description |
string | {string} Resource name string. |
deleteSession(request, options)
deleteSession(request?: protos.google.spanner.v1.IDeleteSessionRequest, options?: CallOptions): Promise<[
protos.google.protobuf.IEmpty,
protos.google.spanner.v1.IDeleteSessionRequest | undefined,
{} | undefined
]>;
Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.
Parameters | |
---|---|
Name | Description |
request |
IDeleteSessionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.protobuf.IEmpty,
protos.google.spanner.v1.IDeleteSessionRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
deleteSession(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IDeleteSessionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
deleteSession(request, callback)
deleteSession(request: protos.google.spanner.v1.IDeleteSessionRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IDeleteSessionRequest
|
callback |
Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
executeBatchDml(request, options)
executeBatchDml(request?: protos.google.spanner.v1.IExecuteBatchDmlRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.IExecuteBatchDmlResponse,
protos.google.spanner.v1.IExecuteBatchDmlRequest | undefined,
{} | undefined
]>;
Executes a batch of SQL DML statements. This method allows many statements to be run with lower latency than submitting them sequentially with .
Statements are executed in sequential order. A request can succeed even if a statement fails. The 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.
Parameters | |
---|---|
Name | Description |
request |
IExecuteBatchDmlRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.IExecuteBatchDmlResponse,
protos.google.spanner.v1.IExecuteBatchDmlRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
executeBatchDml(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IExecuteBatchDmlRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
executeBatchDml(request, callback)
executeBatchDml(request: protos.google.spanner.v1.IExecuteBatchDmlRequest, callback: Callback<protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IExecuteBatchDmlRequest
|
callback |
Callback<protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
executeSql(request, options)
executeSql(request?: protos.google.spanner.v1.IExecuteSqlRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.IResultSet,
protos.google.spanner.v1.IExecuteSqlRequest | undefined,
{} | undefined
]>;
Executes an SQL statement, returning all results in a single reply. This method cannot 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 for more details.
Larger result sets can be fetched in streaming fashion by calling instead.
Parameters | |
---|---|
Name | Description |
request |
IExecuteSqlRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.IResultSet,
protos.google.spanner.v1.IExecuteSqlRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
executeSql(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IExecuteSqlRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
executeSql(request, callback)
executeSql(request: protos.google.spanner.v1.IExecuteSqlRequest, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IExecuteSqlRequest
|
callback |
Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
executeStreamingSql(request, options)
executeStreamingSql(request?: protos.google.spanner.v1.IExecuteSqlRequest, options?: CallOptions): gax.CancellableStream;
Like , except returns the result set as a stream. Unlike , there is no limit on the size of the returned result set. However, no individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB.
Parameters | |
---|---|
Name | Description |
request |
IExecuteSqlRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
gax.CancellableStream | {Stream} An object stream which emits on 'data' event. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) for more details and examples. |
getProjectId()
getProjectId(): Promise<string>;
Returns | |
---|---|
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter | |
---|---|
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Returns | |
---|---|
Type | Description |
void |
getSession(request, options)
getSession(request?: protos.google.spanner.v1.IGetSessionRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.ISession,
protos.google.spanner.v1.IGetSessionRequest | undefined,
{} | undefined
]>;
Gets a session. Returns NOT_FOUND
if the session does not exist. This is mainly useful for determining whether a session is still alive.
Parameters | |
---|---|
Name | Description |
request |
IGetSessionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.ISession,
protos.google.spanner.v1.IGetSessionRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
getSession(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IGetSessionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getSession(request, callback)
getSession(request: protos.google.spanner.v1.IGetSessionRequest, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetSessionRequest
|
callback |
Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
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 | |
---|---|
Type | Description |
Promise<{
[name: string]: Function;
}> | {Promise} A promise that resolves to an authenticated service stub. |
listSessions(request, options)
listSessions(request?: protos.google.spanner.v1.IListSessionsRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.ISession[],
protos.google.spanner.v1.IListSessionsRequest | null,
protos.google.spanner.v1.IListSessionsResponse
]>;
Lists all sessions in a given database.
Parameters | |
---|---|
Name | Description |
request |
IListSessionsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.ISession[],
protos.google.spanner.v1.IListSessionsRequest | null,
protos.google.spanner.v1.IListSessionsResponse
]> | {Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using |
listSessions(request, options, callback)
listSessions(request: protos.google.spanner.v1.IListSessionsRequest, options: CallOptions, callback: PaginationCallback<protos.google.spanner.v1.IListSessionsRequest, protos.google.spanner.v1.IListSessionsResponse | null | undefined, protos.google.spanner.v1.ISession>): void;
Parameters | |
---|---|
Name | Description |
request |
IListSessionsRequest
|
options |
CallOptions
|
callback |
PaginationCallback<protos.google.spanner.v1.IListSessionsRequest, protos.google.spanner.v1.IListSessionsResponse | null | undefined, protos.google.spanner.v1.ISession>
|
Returns | |
---|---|
Type | Description |
void |
listSessions(request, callback)
listSessions(request: protos.google.spanner.v1.IListSessionsRequest, callback: PaginationCallback<protos.google.spanner.v1.IListSessionsRequest, protos.google.spanner.v1.IListSessionsResponse | null | undefined, protos.google.spanner.v1.ISession>): void;
Parameters | |
---|---|
Name | Description |
request |
IListSessionsRequest
|
callback |
PaginationCallback<protos.google.spanner.v1.IListSessionsRequest, protos.google.spanner.v1.IListSessionsResponse | null | undefined, protos.google.spanner.v1.ISession>
|
Returns | |
---|---|
Type | Description |
void |
listSessionsAsync(request, options)
listSessionsAsync(request?: protos.google.spanner.v1.IListSessionsRequest, options?: CallOptions): AsyncIterable<protos.google.spanner.v1.ISession>;
Equivalent to listSessions
, but returns an iterable object.
for
-await
-of
syntax is used with the iterable to get response elements on-demand.
Parameters | |
---|---|
Name | Description |
request |
IListSessionsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
AsyncIterable<protos.google.spanner.v1.ISession> | {Object} An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples. |
listSessionsStream(request, options)
listSessionsStream(request?: protos.google.spanner.v1.IListSessionsRequest, options?: CallOptions): Transform;
Equivalent to method.name.toCamelCase()
, but returns a NodeJS Stream object.
Parameters | |
---|---|
Name | Description |
request |
IListSessionsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Transform | {Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using |
matchDatabaseFromDatabaseName(databaseName)
matchDatabaseFromDatabaseName(databaseName: string): string | number;
Parse the database from Database resource.
Parameter | |
---|---|
Name | Description |
databaseName |
string
A fully-qualified path representing Database resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the database. |
matchDatabaseFromSessionName(sessionName)
matchDatabaseFromSessionName(sessionName: string): string | number;
Parse the database from Session resource.
Parameter | |
---|---|
Name | Description |
sessionName |
string
A fully-qualified path representing Session resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the database. |
matchInstanceFromDatabaseName(databaseName)
matchInstanceFromDatabaseName(databaseName: string): string | number;
Parse the instance from Database resource.
Parameter | |
---|---|
Name | Description |
databaseName |
string
A fully-qualified path representing Database resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the instance. |
matchInstanceFromSessionName(sessionName)
matchInstanceFromSessionName(sessionName: string): string | number;
Parse the instance from Session resource.
Parameter | |
---|---|
Name | Description |
sessionName |
string
A fully-qualified path representing Session resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the instance. |
matchProjectFromDatabaseName(databaseName)
matchProjectFromDatabaseName(databaseName: string): string | number;
Parse the project from Database resource.
Parameter | |
---|---|
Name | Description |
databaseName |
string
A fully-qualified path representing Database resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the project. |
matchProjectFromSessionName(sessionName)
matchProjectFromSessionName(sessionName: string): string | number;
Parse the project from Session resource.
Parameter | |
---|---|
Name | Description |
sessionName |
string
A fully-qualified path representing Session resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the project. |
matchSessionFromSessionName(sessionName)
matchSessionFromSessionName(sessionName: string): string | number;
Parse the session from Session resource.
Parameter | |
---|---|
Name | Description |
sessionName |
string
A fully-qualified path representing Session resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the session. |
partitionQuery(request, options)
partitionQuery(request?: protos.google.spanner.v1.IPartitionQueryRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.IPartitionResponse,
protos.google.spanner.v1.IPartitionQueryRequest | undefined,
{} | undefined
]>;
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 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 is not possible to resume the query, and the whole operation must be restarted from the beginning.
Parameters | |
---|---|
Name | Description |
request |
IPartitionQueryRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.IPartitionResponse,
protos.google.spanner.v1.IPartitionQueryRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
partitionQuery(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IPartitionQueryRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
partitionQuery(request, callback)
partitionQuery(request: protos.google.spanner.v1.IPartitionQueryRequest, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IPartitionQueryRequest
|
callback |
Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
partitionRead(request, options)
partitionRead(request?: protos.google.spanner.v1.IPartitionReadRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.IPartitionResponse,
protos.google.spanner.v1.IPartitionReadRequest | undefined,
{} | undefined
]>;
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 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 is not possible to resume the read, and the whole operation must be restarted from the beginning.
Parameters | |
---|---|
Name | Description |
request |
IPartitionReadRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.IPartitionResponse,
protos.google.spanner.v1.IPartitionReadRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
partitionRead(request, options, callback)
partitionRead(request: protos.google.spanner.v1.IPartitionReadRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionReadRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IPartitionReadRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionReadRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
partitionRead(request, callback)
partitionRead(request: protos.google.spanner.v1.IPartitionReadRequest, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionReadRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IPartitionReadRequest
|
callback |
Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionReadRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
read(request, options)
read(request?: protos.google.spanner.v1.IReadRequest, options?: CallOptions): Promise<[
protos.google.spanner.v1.IResultSet,
protos.google.spanner.v1.IReadRequest | undefined,
{} | undefined
]>;
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to . This method cannot 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 for more details.
Larger result sets can be yielded in streaming fashion by calling instead.
Parameters | |
---|---|
Name | Description |
request |
IReadRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.spanner.v1.IResultSet,
protos.google.spanner.v1.IReadRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
read(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IReadRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
read(request, callback)
read(request: protos.google.spanner.v1.IReadRequest, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IReadRequest
|
callback |
Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
rollback(request, options)
rollback(request?: protos.google.spanner.v1.IRollbackRequest, options?: CallOptions): Promise<[
protos.google.protobuf.IEmpty,
protos.google.spanner.v1.IRollbackRequest | undefined,
{} | undefined
]>;
Rolls back a transaction, releasing any locks it holds. It is a good idea to call this for any transaction that includes one or more or requests and ultimately decides not to commit.
Rollback
returns OK
if it successfully aborts the transaction, the transaction was already aborted, or the transaction is not found. Rollback
never returns ABORTED
.
Parameters | |
---|---|
Name | Description |
request |
IRollbackRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.protobuf.IEmpty,
protos.google.spanner.v1.IRollbackRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
rollback(request, options, callback)
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;
Parameters | |
---|---|
Name | Description |
request |
IRollbackRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
rollback(request, callback)
rollback(request: protos.google.spanner.v1.IRollbackRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IRollbackRequest
|
callback |
Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
sessionPath(project, instance, database, session)
sessionPath(project: string, instance: string, database: string, session: string): string;
Return a fully-qualified session resource name string.
Parameters | |
---|---|
Name | Description |
project |
string
|
instance |
string
|
database |
string
|
session |
string
|
Returns | |
---|---|
Type | Description |
string | {string} Resource name string. |
streamingRead(request, options)
streamingRead(request?: protos.google.spanner.v1.IReadRequest, options?: CallOptions): gax.CancellableStream;
Like , except returns the result set as a stream. Unlike , there is no limit on the size of the returned result set. However, no individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB.
Parameters | |
---|---|
Name | Description |
request |
IReadRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
gax.CancellableStream | {Stream} An object stream which emits on 'data' event. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) for more details and examples. |