@google-cloud/spanner 7.17.0 → 7.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/build/protos/google/spanner/admin/database/v1/backup.proto +0 -757
- package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +0 -230
- package/build/protos/google/spanner/admin/database/v1/common.proto +0 -132
- package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +0 -1209
- package/build/protos/google/spanner/admin/instance/v1/common.proto +0 -63
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +0 -1983
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +0 -1520
- package/build/protos/google/spanner/v1/commit_response.proto +0 -59
- package/build/protos/google/spanner/v1/keys.proto +0 -163
- package/build/protos/google/spanner/v1/mutation.proto +0 -107
- package/build/protos/google/spanner/v1/query_plan.proto +0 -128
- package/build/protos/google/spanner/v1/result_set.proto +0 -237
- package/build/protos/google/spanner/v1/spanner.proto +0 -1389
- package/build/protos/google/spanner/v1/transaction.proto +0 -575
- package/build/protos/google/spanner/v1/type.proto +0 -210
- package/build/protos/protos.d.ts +0 -38999
- package/build/protos/protos.js +0 -99538
- package/build/protos/protos.json +0 -10182
- package/build/src/backup.d.ts +0 -349
- package/build/src/backup.js +0 -246
- package/build/src/batch-transaction.d.ts +0 -247
- package/build/src/batch-transaction.js +0 -384
- package/build/src/codec.d.ts +0 -362
- package/build/src/codec.js +0 -791
- package/build/src/common-grpc/service-object.d.ts +0 -80
- package/build/src/common-grpc/service-object.js +0 -101
- package/build/src/common-grpc/service.d.ts +0 -445
- package/build/src/common-grpc/service.js +0 -826
- package/build/src/common.d.ts +0 -66
- package/build/src/common.js +0 -54
- package/build/src/database.d.ts +0 -2104
- package/build/src/database.js +0 -1655
- package/build/src/extra_proto_list.json +0 -1
- package/build/src/helper.d.ts +0 -45
- package/build/src/helper.js +0 -71
- package/build/src/index.d.ts +0 -1195
- package/build/src/index.js +0 -1060
- package/build/src/instance-config.d.ts +0 -295
- package/build/src/instance-config.js +0 -216
- package/build/src/instance.d.ts +0 -833
- package/build/src/instance.js +0 -781
- package/build/src/instrument.d.ts +0 -87
- package/build/src/instrument.js +0 -217
- package/build/src/multiplexed-session.d.ts +0 -136
- package/build/src/multiplexed-session.js +0 -197
- package/build/src/partial-result-stream.d.ts +0 -253
- package/build/src/partial-result-stream.js +0 -400
- package/build/src/session-factory.d.ts +0 -101
- package/build/src/session-factory.js +0 -93
- package/build/src/session-pool.d.ts +0 -471
- package/build/src/session-pool.js +0 -754
- package/build/src/session.d.ts +0 -259
- package/build/src/session.js +0 -348
- package/build/src/spanner_grpc_config.json +0 -92
- package/build/src/table.d.ts +0 -831
- package/build/src/table.js +0 -277
- package/build/src/transaction-runner.d.ts +0 -185
- package/build/src/transaction-runner.js +0 -282
- package/build/src/transaction.d.ts +0 -1691
- package/build/src/transaction.js +0 -2004
- package/build/src/v1/database_admin_client.d.ts +0 -2301
- package/build/src/v1/database_admin_client.js +0 -2286
- package/build/src/v1/database_admin_client_config.json +0 -160
- package/build/src/v1/database_admin_proto_list.json +0 -6
- package/build/src/v1/gapic_metadata.json +0 -27
- package/build/src/v1/index.d.ts +0 -4
- package/build/src/v1/index.js +0 -29
- package/build/src/v1/instance_admin_client.d.ts +0 -1982
- package/build/src/v1/instance_admin_client.js +0 -1766
- package/build/src/v1/instance_admin_client_config.json +0 -129
- package/build/src/v1/instance_admin_proto_list.json +0 -4
- package/build/src/v1/spanner_client.d.ts +0 -1250
- package/build/src/v1/spanner_client.js +0 -1086
- package/build/src/v1/spanner_client_config.json +0 -119
- package/build/src/v1/spanner_executor_proxy_client.d.ts +0 -418
- package/build/src/v1/spanner_executor_proxy_client.js +0 -706
- package/build/src/v1/spanner_executor_proxy_client_config.json +0 -30
- package/build/src/v1/spanner_executor_proxy_proto_list.json +0 -14
- package/build/src/v1/spanner_proto_list.json +0 -10
package/build/src/database.d.ts
DELETED
|
@@ -1,2104 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2016 Google Inc. All Rights Reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { ExistsCallback, GetConfig } from '@google-cloud/common';
|
|
17
|
-
declare const common: any;
|
|
18
|
-
import * as r from 'teeny-request';
|
|
19
|
-
import { CallOptions, Operation as GaxOperation } from 'google-gax';
|
|
20
|
-
import { BatchTransaction, TransactionIdentifier } from './batch-transaction';
|
|
21
|
-
import { SessionFactoryInterface } from './session-factory';
|
|
22
|
-
import { google as databaseAdmin, google, google as spannerClient } from '../protos/protos';
|
|
23
|
-
import { GetDatabaseOperationsOptions, GetDatabaseOperationsResponse, Instance, GetDatabaseOperationsCallback } from './instance';
|
|
24
|
-
import { PartialResultStream } from './partial-result-stream';
|
|
25
|
-
import { Session } from './session';
|
|
26
|
-
import { SessionPoolCloseCallback, SessionPoolInterface, SessionPoolOptions } from './session-pool';
|
|
27
|
-
import { CreateTableCallback, CreateTableResponse, Table } from './table';
|
|
28
|
-
import { BatchWriteOptions, CommitCallback, CommitResponse, ExecuteSqlRequest, MutationGroup, MutationSet, RunCallback, RunResponse, RunUpdateCallback, Snapshot, TimestampBounds, Transaction } from './transaction';
|
|
29
|
-
import { AsyncRunTransactionCallback, RunTransactionCallback, RunTransactionOptions } from './transaction-runner';
|
|
30
|
-
import { IOperation, LongRunningCallback, NormalCallback, PagedOptionsWithFilter, PagedResponse, RequestCallback, ResourceCallback, Schema } from './common';
|
|
31
|
-
import { Duplex, Readable } from 'stream';
|
|
32
|
-
import { EnumKey, RequestConfig, TranslateEnumKeys } from '.';
|
|
33
|
-
import IPolicy = google.iam.v1.IPolicy;
|
|
34
|
-
import Policy = google.iam.v1.Policy;
|
|
35
|
-
import FieldMask = google.protobuf.FieldMask;
|
|
36
|
-
import IDatabase = google.spanner.admin.database.v1.IDatabase;
|
|
37
|
-
import { ObservabilityOptions } from './instrument';
|
|
38
|
-
export type GetDatabaseRolesCallback = RequestCallback<IDatabaseRole, databaseAdmin.spanner.admin.database.v1.IListDatabaseRolesResponse>;
|
|
39
|
-
export type GetDatabaseRolesResponse = PagedResponse<IDatabaseRole, databaseAdmin.spanner.admin.database.v1.IListDatabaseRolesResponse>;
|
|
40
|
-
type SetDatabaseMetadataCallback = ResourceCallback<GaxOperation, IOperation>;
|
|
41
|
-
type SetDatabaseMetadataResponse = [GaxOperation, IOperation];
|
|
42
|
-
type IDatabaseRole = databaseAdmin.spanner.admin.database.v1.IDatabaseRole;
|
|
43
|
-
type CreateBatchTransactionCallback = ResourceCallback<BatchTransaction, google.spanner.v1.ITransaction | google.spanner.v1.ISession>;
|
|
44
|
-
type CreateBatchTransactionResponse = [
|
|
45
|
-
BatchTransaction,
|
|
46
|
-
google.spanner.v1.ITransaction | google.spanner.v1.ISession
|
|
47
|
-
];
|
|
48
|
-
type DatabaseResponse = [Database, r.Response];
|
|
49
|
-
type DatabaseCallback = ResourceCallback<Database, r.Response>;
|
|
50
|
-
type GetSnapshotCallback = NormalCallback<Snapshot>;
|
|
51
|
-
type GetTransactionCallback = NormalCallback<Transaction>;
|
|
52
|
-
export interface SessionPoolConstructor {
|
|
53
|
-
new (database: Database, options?: SessionPoolOptions | null): SessionPoolInterface;
|
|
54
|
-
}
|
|
55
|
-
export type GetDatabaseDialectCallback = NormalCallback<EnumKey<typeof google.spanner.admin.database.v1.DatabaseDialect>>;
|
|
56
|
-
export interface SetIamPolicyRequest {
|
|
57
|
-
policy: Policy | null;
|
|
58
|
-
updateMask?: FieldMask | null;
|
|
59
|
-
}
|
|
60
|
-
export interface RunPartitionedUpdateOptions extends ExecuteSqlRequest {
|
|
61
|
-
excludeTxnFromChangeStreams?: boolean;
|
|
62
|
-
}
|
|
63
|
-
export type UpdateSchemaCallback = ResourceCallback<GaxOperation, databaseAdmin.longrunning.IOperation>;
|
|
64
|
-
export type UpdateSchemaResponse = [
|
|
65
|
-
GaxOperation,
|
|
66
|
-
databaseAdmin.longrunning.IOperation
|
|
67
|
-
];
|
|
68
|
-
type PoolRequestCallback = RequestCallback<Session>;
|
|
69
|
-
export type GetSessionsOptions = PagedOptionsWithFilter;
|
|
70
|
-
export type GetDatabaseRolesOptions = PagedOptionsWithFilter;
|
|
71
|
-
/**
|
|
72
|
-
* IDatabase structure with database state enum translated to string form.
|
|
73
|
-
*/
|
|
74
|
-
type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'databaseDialect', typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect>, 'restoreInfo'> & {
|
|
75
|
-
restoreInfo?: IRestoreInfoTranslatedEnum | null;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* IRestoreInfo structure with restore source type enum translated to string form.
|
|
79
|
-
*/
|
|
80
|
-
type IRestoreInfoTranslatedEnum = TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IRestoreInfo, 'sourceType', typeof databaseAdmin.spanner.admin.database.v1.RestoreSourceType>;
|
|
81
|
-
type GetDatabaseMetadataResponse = [IDatabaseTranslatedEnum];
|
|
82
|
-
type GetDatabaseMetadataCallback = RequestCallback<IDatabaseTranslatedEnum>;
|
|
83
|
-
type GetSchemaCallback = RequestCallback<string, databaseAdmin.spanner.admin.database.v1.IGetDatabaseDdlResponse>;
|
|
84
|
-
type GetSchemaResponse = [
|
|
85
|
-
string[],
|
|
86
|
-
databaseAdmin.spanner.admin.database.v1.IGetDatabaseDdlResponse
|
|
87
|
-
];
|
|
88
|
-
type GetIamPolicyResponse = IPolicy;
|
|
89
|
-
type GetIamPolicyCallback = RequestCallback<IPolicy>;
|
|
90
|
-
type SetIamPolicyResponse = IPolicy;
|
|
91
|
-
type SetIamPolicyCallback = RequestCallback<IPolicy>;
|
|
92
|
-
type GetSessionsCallback = RequestCallback<Session, google.spanner.v1.IListSessionsResponse>;
|
|
93
|
-
type GetSessionsResponse = PagedResponse<Session, google.spanner.v1.IListSessionsResponse>;
|
|
94
|
-
export type GetDatabaseConfig = GetConfig & databaseAdmin.spanner.admin.database.v1.IGetDatabaseRequest & {
|
|
95
|
-
gaxOptions?: CallOptions;
|
|
96
|
-
};
|
|
97
|
-
type DatabaseCloseResponse = [google.protobuf.IEmpty];
|
|
98
|
-
export type CreateSessionResponse = [
|
|
99
|
-
Session,
|
|
100
|
-
spannerClient.spanner.v1.ISession
|
|
101
|
-
];
|
|
102
|
-
export interface CreateSessionOptions {
|
|
103
|
-
labels?: {
|
|
104
|
-
[k: string]: string;
|
|
105
|
-
} | null;
|
|
106
|
-
databaseRole?: string | null;
|
|
107
|
-
gaxOptions?: CallOptions;
|
|
108
|
-
multiplexed?: boolean;
|
|
109
|
-
}
|
|
110
|
-
export interface GetIamPolicyOptions {
|
|
111
|
-
requestedPolicyVersion?: number | null;
|
|
112
|
-
gaxOptions?: CallOptions;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* @typedef {object} GetTransactionOptions
|
|
116
|
-
* * @property {boolean} [optimisticLock] The optimistic lock a
|
|
117
|
-
* {@link Transaction} should use while running.
|
|
118
|
-
*/
|
|
119
|
-
export type GetTransactionOptions = Omit<RunTransactionOptions, 'timeout'>;
|
|
120
|
-
export type CreateSessionCallback = ResourceCallback<Session, spannerClient.spanner.v1.ISession>;
|
|
121
|
-
export interface BatchCreateSessionsOptions extends CreateSessionOptions {
|
|
122
|
-
count: number;
|
|
123
|
-
}
|
|
124
|
-
export type BatchCreateSessionsResponse = [
|
|
125
|
-
Session[],
|
|
126
|
-
spannerClient.spanner.v1.IBatchCreateSessionsResponse
|
|
127
|
-
];
|
|
128
|
-
export type BatchCreateSessionsCallback = ResourceCallback<Session[], spannerClient.spanner.v1.IBatchCreateSessionsResponse>;
|
|
129
|
-
export type DatabaseDeleteResponse = [databaseAdmin.protobuf.IEmpty];
|
|
130
|
-
export type DatabaseDeleteCallback = NormalCallback<databaseAdmin.protobuf.IEmpty>;
|
|
131
|
-
export interface CancelableDuplex extends Duplex {
|
|
132
|
-
cancel(): void;
|
|
133
|
-
}
|
|
134
|
-
export type RestoreDatabaseCallback = LongRunningCallback<Database>;
|
|
135
|
-
export type RestoreDatabaseResponse = [
|
|
136
|
-
Database,
|
|
137
|
-
GaxOperation,
|
|
138
|
-
databaseAdmin.longrunning.IOperation
|
|
139
|
-
];
|
|
140
|
-
export type GetRestoreInfoCallback = NormalCallback<IRestoreInfoTranslatedEnum>;
|
|
141
|
-
export type GetStateCallback = NormalCallback<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Database.State>>;
|
|
142
|
-
interface DatabaseRequest {
|
|
143
|
-
(config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
|
|
144
|
-
<T>(config: RequestConfig, callback: RequestCallback<T>): void;
|
|
145
|
-
<T, R>(config: RequestConfig, callback: RequestCallback<T, R>): void;
|
|
146
|
-
}
|
|
147
|
-
export interface RestoreOptions {
|
|
148
|
-
encryptionConfig?: databaseAdmin.spanner.admin.database.v1.IRestoreDatabaseEncryptionConfig;
|
|
149
|
-
gaxOptions?: CallOptions;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Create a Database object to interact with a Cloud Spanner database.
|
|
153
|
-
*
|
|
154
|
-
* @class
|
|
155
|
-
*
|
|
156
|
-
* @param {string} name Name of the database.
|
|
157
|
-
* @param {SessionPoolOptions|SessionPoolInterface} options Session pool
|
|
158
|
-
* configuration options or custom pool interface.
|
|
159
|
-
* @param {google.spanner.v1.ExecuteSqlRequest.IQueryOptions} queryOptions
|
|
160
|
-
* The default query options to use for queries on the database.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```
|
|
164
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
165
|
-
* const spanner = new Spanner();
|
|
166
|
-
* const instance = spanner.instance('my-instance');
|
|
167
|
-
* const database = instance.database('my-database');
|
|
168
|
-
* ```
|
|
169
|
-
*/
|
|
170
|
-
declare class Database extends common.GrpcServiceObject {
|
|
171
|
-
static [x: string]: any;
|
|
172
|
-
private instance;
|
|
173
|
-
formattedName_: string;
|
|
174
|
-
pool_: SessionPoolInterface;
|
|
175
|
-
sessionFactory_: SessionFactoryInterface;
|
|
176
|
-
queryOptions_?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions;
|
|
177
|
-
commonHeaders_: {
|
|
178
|
-
[k: string]: string;
|
|
179
|
-
};
|
|
180
|
-
request: DatabaseRequest;
|
|
181
|
-
databaseRole?: string | null;
|
|
182
|
-
labels?: {
|
|
183
|
-
[k: string]: string;
|
|
184
|
-
} | null;
|
|
185
|
-
databaseDialect?: EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | null;
|
|
186
|
-
_observabilityOptions?: ObservabilityOptions;
|
|
187
|
-
private _traceConfig;
|
|
188
|
-
constructor(instance: Instance, name: string, poolOptions?: SessionPoolConstructor | SessionPoolOptions, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions);
|
|
189
|
-
/**
|
|
190
|
-
* @typedef {array} SetDatabaseMetadataResponse
|
|
191
|
-
* @property {object} 0 The {@link Database} metadata.
|
|
192
|
-
* @property {object} 1 The full API response.
|
|
193
|
-
*/
|
|
194
|
-
/**
|
|
195
|
-
* @callback SetDatabaseMetadataCallback
|
|
196
|
-
* @param {?Error} err Request error, if any.
|
|
197
|
-
* @param {object} metadata The {@link Database} metadata.
|
|
198
|
-
* @param {object} apiResponse The full API response.
|
|
199
|
-
*/
|
|
200
|
-
/**
|
|
201
|
-
* Update the metadata for this database. Note that this method follows PATCH
|
|
202
|
-
* semantics, so previously-configured settings will persist.
|
|
203
|
-
*
|
|
204
|
-
* Wrapper around {@link v1.DatabaseAdminClient#updateDatabase}.
|
|
205
|
-
*
|
|
206
|
-
* @see {@link v1.DatabaseAdminClient#updateDatabase}
|
|
207
|
-
* @see [UpdateDatabase API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase)
|
|
208
|
-
*
|
|
209
|
-
* @param {object} metadata The metadata you wish to set.
|
|
210
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
211
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
212
|
-
* for more details.
|
|
213
|
-
* @param {SetDatabaseMetadataCallback} [callback] Callback function.
|
|
214
|
-
* @returns {Promise<SetDatabaseMetadataResponse>}
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```
|
|
218
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
219
|
-
* const spanner = new Spanner();
|
|
220
|
-
*
|
|
221
|
-
* const instance = spanner.instance('my-instance');
|
|
222
|
-
* const database = instance.database('my-database');
|
|
223
|
-
*
|
|
224
|
-
* const metadata = {
|
|
225
|
-
* enableDropProtection: true
|
|
226
|
-
* };
|
|
227
|
-
*
|
|
228
|
-
* database.setMetadata(metadata, function(err, operation, apiResponse) {
|
|
229
|
-
* if (err) {
|
|
230
|
-
* // Error handling omitted.
|
|
231
|
-
* }
|
|
232
|
-
*
|
|
233
|
-
* operation
|
|
234
|
-
* .on('error', function(err) {})
|
|
235
|
-
* .on('complete', function() {
|
|
236
|
-
* // Metadata updated successfully.
|
|
237
|
-
* });
|
|
238
|
-
* });
|
|
239
|
-
*
|
|
240
|
-
* //-
|
|
241
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
242
|
-
* //-
|
|
243
|
-
* database.setMetadata(metadata).then(function(data) {
|
|
244
|
-
* const operation = data[0];
|
|
245
|
-
* const apiResponse = data[1];
|
|
246
|
-
* });
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
setMetadata(metadata: IDatabase, gaxOptions?: CallOptions): Promise<SetDatabaseMetadataResponse>;
|
|
250
|
-
setMetadata(metadata: IDatabase, callback: SetDatabaseMetadataCallback): void;
|
|
251
|
-
setMetadata(metadata: IDatabase, gaxOptions: CallOptions, callback: SetDatabaseMetadataCallback): void;
|
|
252
|
-
static getEnvironmentQueryOptions(): databaseAdmin.spanner.v1.ExecuteSqlRequest.IQueryOptions;
|
|
253
|
-
/**
|
|
254
|
-
* @typedef {object} BatchCreateSessionsOptions
|
|
255
|
-
* @property {number} count The number of sessions to create.
|
|
256
|
-
* @property {object.<string, string>} [labels] Labels to apply to each
|
|
257
|
-
* session.
|
|
258
|
-
* @property {object} [gaxOptions] Request configuration options,
|
|
259
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
260
|
-
* for more details.
|
|
261
|
-
*/
|
|
262
|
-
/**
|
|
263
|
-
* @typedef {array} BatchCreateSessionsResponse
|
|
264
|
-
* @property {Session[]} 0 The newly created sessions.
|
|
265
|
-
* @property {object} 1 The full API response.
|
|
266
|
-
*/
|
|
267
|
-
/**
|
|
268
|
-
* @callback BatchCreateSessionsCallback
|
|
269
|
-
* @param {?Error} err Request error, if any.
|
|
270
|
-
* @param {Session[]} sessions The newly created sessions.
|
|
271
|
-
* @param {object} apiResponse The full API response.
|
|
272
|
-
*/
|
|
273
|
-
/**
|
|
274
|
-
* Create a batch of sessions, which can be used to perform transactions that
|
|
275
|
-
* read and/or modify data.
|
|
276
|
-
*
|
|
277
|
-
* **It is unlikely you will need to interact with sessions directly. By
|
|
278
|
-
* default, sessions are created and utilized for maximum performance
|
|
279
|
-
* automatically.**
|
|
280
|
-
*
|
|
281
|
-
* Wrapper around {@link v1.SpannerClient#batchCreateSessions}.
|
|
282
|
-
*
|
|
283
|
-
* @see {@link v1.SpannerClient#batchCreateSessions}
|
|
284
|
-
* @see [BatchCreateSessions API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.BatchCreateSessions)
|
|
285
|
-
*
|
|
286
|
-
* @param {number|BatchCreateSessionsOptions} options Desired session count or
|
|
287
|
-
* a configuration object.
|
|
288
|
-
* @param {BatchCreateSessionsCallback} [callback] Callback function.
|
|
289
|
-
* @returns {Promise<BatchCreateSessionsResponse>}
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* ```
|
|
293
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
294
|
-
* const spanner = new Spanner();
|
|
295
|
-
*
|
|
296
|
-
* const instance = spanner.instance('my-instance');
|
|
297
|
-
* const database = instance.database('my-database');
|
|
298
|
-
*
|
|
299
|
-
* const count = 5;
|
|
300
|
-
*
|
|
301
|
-
* database.batchCreateSession(count, (err, sessions, response) => {
|
|
302
|
-
* if (err) {
|
|
303
|
-
* // Error handling omitted.
|
|
304
|
-
* }
|
|
305
|
-
*
|
|
306
|
-
* // `sessions` is an array of Session objects.
|
|
307
|
-
* });
|
|
308
|
-
*
|
|
309
|
-
* ```
|
|
310
|
-
* @example If the callback is omitted, we'll return a Promise.
|
|
311
|
-
* ```
|
|
312
|
-
* const [sessions, response] = await database.batchCreateSessions(count);
|
|
313
|
-
* ```
|
|
314
|
-
*/
|
|
315
|
-
batchCreateSessions(options: number | BatchCreateSessionsOptions): Promise<BatchCreateSessionsResponse>;
|
|
316
|
-
batchCreateSessions(options: number | BatchCreateSessionsOptions, callback: BatchCreateSessionsCallback): void;
|
|
317
|
-
/**
|
|
318
|
-
* Get a reference to a {@link BatchTransaction} object.
|
|
319
|
-
*
|
|
320
|
-
* @see {@link BatchTransaction#identifier} to generate an identifier.
|
|
321
|
-
*
|
|
322
|
-
* @param {TransactionIdentifier} identifier The transaction identifier.
|
|
323
|
-
* @param {object} [options] [Transaction options](https://cloud.google.com/spanner/docs/timestamp-bounds).
|
|
324
|
-
* @returns {BatchTransaction} A batch transaction object.
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* ```
|
|
328
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
329
|
-
* const spanner = new Spanner();
|
|
330
|
-
*
|
|
331
|
-
* const instance = spanner.instance('my-instance');
|
|
332
|
-
* const database = instance.database('my-database');
|
|
333
|
-
*
|
|
334
|
-
* const transaction = database.batchTransaction({
|
|
335
|
-
* session: 'my-session',
|
|
336
|
-
* transaction: 'my-transaction',
|
|
337
|
-
* readTimestamp: 1518464696657
|
|
338
|
-
* });
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
batchTransaction(identifier: TransactionIdentifier, options?: TimestampBounds): BatchTransaction;
|
|
342
|
-
/**
|
|
343
|
-
* @callback CloseDatabaseCallback
|
|
344
|
-
* @param {?Error} err Request error, if any.
|
|
345
|
-
*/
|
|
346
|
-
/**
|
|
347
|
-
* Close the database connection and destroy all sessions associated with it.
|
|
348
|
-
*
|
|
349
|
-
* @param {CloseDatabaseCallback} [callback] Callback function.
|
|
350
|
-
* @returns {Promise}
|
|
351
|
-
*
|
|
352
|
-
* @example
|
|
353
|
-
* ```
|
|
354
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
355
|
-
* const spanner = new Spanner();
|
|
356
|
-
*
|
|
357
|
-
* const instance = spanner.instance('my-instance');
|
|
358
|
-
* const database = instance.database('my-database');
|
|
359
|
-
*
|
|
360
|
-
* database.close(function(err) {
|
|
361
|
-
* if (err) {
|
|
362
|
-
* // Error handling omitted.
|
|
363
|
-
* }
|
|
364
|
-
* });
|
|
365
|
-
*
|
|
366
|
-
* //-
|
|
367
|
-
* // In the event of a session leak, the error object will contain a
|
|
368
|
-
* // `messages` field.
|
|
369
|
-
* //-
|
|
370
|
-
* database.close(function(err) {
|
|
371
|
-
* if (err && err.messages) {
|
|
372
|
-
* err.messages.forEach(function(message) {
|
|
373
|
-
* console.error(message);
|
|
374
|
-
* });
|
|
375
|
-
* }
|
|
376
|
-
* });
|
|
377
|
-
* ```
|
|
378
|
-
*/
|
|
379
|
-
close(callback: SessionPoolCloseCallback): void;
|
|
380
|
-
close(): Promise<DatabaseCloseResponse>;
|
|
381
|
-
/**
|
|
382
|
-
* @typedef {array} CreateTransactionResponse
|
|
383
|
-
* @property {BatchTransaction} 0 The {@link BatchTransaction}.
|
|
384
|
-
* @property {object} 1 The full API response.
|
|
385
|
-
*/
|
|
386
|
-
/**
|
|
387
|
-
* @callback CreateTransactionCallback
|
|
388
|
-
* @param {?Error} err Request error, if any.
|
|
389
|
-
* @param {BatchTransaction} transaction The {@link BatchTransaction}.
|
|
390
|
-
* @param {object} apiResponse The full API response.
|
|
391
|
-
*/
|
|
392
|
-
/**
|
|
393
|
-
* Create a transaction that can be used for batch querying.
|
|
394
|
-
*
|
|
395
|
-
* @param {object} [options] [Transaction options](https://cloud.google.com/spanner/docs/timestamp-bounds).
|
|
396
|
-
* @param {CreateTransactionCallback} [callback] Callback function.
|
|
397
|
-
* @returns {Promise<CreateTransactionResponse>}
|
|
398
|
-
*/
|
|
399
|
-
createBatchTransaction(options?: TimestampBounds): Promise<CreateBatchTransactionResponse>;
|
|
400
|
-
createBatchTransaction(callback: CreateBatchTransactionCallback): void;
|
|
401
|
-
createBatchTransaction(options: TimestampBounds, callback: CreateBatchTransactionCallback): void;
|
|
402
|
-
/**
|
|
403
|
-
* Create a new session.
|
|
404
|
-
*
|
|
405
|
-
* @typedef {object} CreateSessionOptions
|
|
406
|
-
* @property {Object.<string, string>} [labels] The labels for the session.
|
|
407
|
-
*
|
|
408
|
-
* * Label keys must be between 1 and 63 characters long and must conform to
|
|
409
|
-
* the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.
|
|
410
|
-
* * Label values must be between 0 and 63 characters long and must conform
|
|
411
|
-
* to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
|
|
412
|
-
* * No more than 64 labels can be associated with a given session.
|
|
413
|
-
* @property {object} [gaxOptions] Request configuration options,
|
|
414
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
415
|
-
* for more details.
|
|
416
|
-
*/
|
|
417
|
-
/**
|
|
418
|
-
* @typedef {array} CreateSessionResponse
|
|
419
|
-
* @property {Session} 0 The newly created session.
|
|
420
|
-
* @property {object} 1 The full API response.
|
|
421
|
-
*/
|
|
422
|
-
/**
|
|
423
|
-
* @callback CreateSessionCallback
|
|
424
|
-
* @param {?Error} err Request error, if any.
|
|
425
|
-
* @param {Session} session The newly created session.
|
|
426
|
-
* @param {object} apiResponse The full API response.
|
|
427
|
-
*/
|
|
428
|
-
/**
|
|
429
|
-
* Create a new session, which can be used to perform transactions that read
|
|
430
|
-
* and/or modify data.
|
|
431
|
-
*
|
|
432
|
-
* Sessions can only execute one transaction at a time. To execute multiple
|
|
433
|
-
* concurrent read-write/write-only transactions, create multiple sessions.
|
|
434
|
-
* Note that standalone reads and queries use a transaction internally, and
|
|
435
|
-
* count toward the one transaction limit.
|
|
436
|
-
*
|
|
437
|
-
* **It is unlikely you will need to interact with sessions directly. By
|
|
438
|
-
* default, sessions are created and utilized for maximum performance
|
|
439
|
-
* automatically.**
|
|
440
|
-
*
|
|
441
|
-
* Wrapper around {@link v1.SpannerClient#createSession}.
|
|
442
|
-
*
|
|
443
|
-
* @see {@link v1.SpannerClient#createSession}
|
|
444
|
-
* @see [CreateSession API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.CreateSession)
|
|
445
|
-
*
|
|
446
|
-
* @param {CreateSessionOptions} [options] Configuration object.
|
|
447
|
-
* @param {CreateSessionCallback} [callback] Callback function.
|
|
448
|
-
* @returns {Promise<CreateSessionResponse>}
|
|
449
|
-
*
|
|
450
|
-
* @example
|
|
451
|
-
* ```
|
|
452
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
453
|
-
* const spanner = new Spanner();
|
|
454
|
-
*
|
|
455
|
-
* const instance = spanner.instance('my-instance');
|
|
456
|
-
* const database = instance.database('my-database');
|
|
457
|
-
*
|
|
458
|
-
* database.createSession(function(err, session, apiResponse) {
|
|
459
|
-
* if (err) {
|
|
460
|
-
* // Error handling omitted.
|
|
461
|
-
* }
|
|
462
|
-
*
|
|
463
|
-
* // `session` is a Session object.
|
|
464
|
-
* });
|
|
465
|
-
*
|
|
466
|
-
* //-
|
|
467
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
468
|
-
* //-
|
|
469
|
-
* database.createSession().then(function(data) {
|
|
470
|
-
* const session = data[0];
|
|
471
|
-
* const apiResponse = data[1];
|
|
472
|
-
* });
|
|
473
|
-
* ```
|
|
474
|
-
*/
|
|
475
|
-
createSession(options: CreateSessionOptions): Promise<CreateSessionResponse>;
|
|
476
|
-
createSession(callback: CreateSessionCallback): void;
|
|
477
|
-
createSession(options: CreateSessionOptions, callback: CreateSessionCallback): void;
|
|
478
|
-
/**
|
|
479
|
-
* @typedef {array} CreateTableResponse
|
|
480
|
-
* @property {Table} 0 The new {@link Table}.
|
|
481
|
-
* @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
|
|
482
|
-
* the status of the request.
|
|
483
|
-
* @property {object} 2 The full API response.
|
|
484
|
-
*/
|
|
485
|
-
/**
|
|
486
|
-
* @callback CreateTableCallback
|
|
487
|
-
* @param {?Error} err Request error, if any.
|
|
488
|
-
* @param {Table} table The new {@link Table}.
|
|
489
|
-
* @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
|
|
490
|
-
* check the status of the request.
|
|
491
|
-
* @param {object} apiResponse The full API response.
|
|
492
|
-
*/
|
|
493
|
-
/**
|
|
494
|
-
* Create a table.
|
|
495
|
-
*
|
|
496
|
-
* Wrapper around {@link Database#updateSchema}.
|
|
497
|
-
*
|
|
498
|
-
* @see {@link Database#updateSchema}
|
|
499
|
-
*
|
|
500
|
-
* @param {string} schema A DDL CREATE statement describing the table.
|
|
501
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
502
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
503
|
-
* for more details.
|
|
504
|
-
* @param {CreateTableCallback} [callback] Callback function.
|
|
505
|
-
* @returns {Promise<CreateTableResponse>}
|
|
506
|
-
*
|
|
507
|
-
* @example
|
|
508
|
-
* ```
|
|
509
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
510
|
-
* const spanner = new Spanner();
|
|
511
|
-
*
|
|
512
|
-
* const instance = spanner.instance('my-instance');
|
|
513
|
-
* const database = instance.database('my-database');
|
|
514
|
-
*
|
|
515
|
-
* const schema =
|
|
516
|
-
* 'CREATE TABLE Singers (' +
|
|
517
|
-
* ' SingerId INT64 NOT NULL,' +
|
|
518
|
-
* ' FirstName STRING(1024),' +
|
|
519
|
-
* ' LastName STRING(1024),' +
|
|
520
|
-
* ' SingerInfo BYTES(MAX),' +
|
|
521
|
-
* ') PRIMARY KEY(SingerId)';
|
|
522
|
-
*
|
|
523
|
-
* database.createTable(schema, function(err, table, operation, apiResponse) {
|
|
524
|
-
* if (err) {
|
|
525
|
-
* // Error handling omitted.
|
|
526
|
-
* }
|
|
527
|
-
*
|
|
528
|
-
* operation
|
|
529
|
-
* .on('error', function(err) {})
|
|
530
|
-
* .on('complete', function() {
|
|
531
|
-
* // Table created successfully.
|
|
532
|
-
* });
|
|
533
|
-
* });
|
|
534
|
-
*
|
|
535
|
-
* //-
|
|
536
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
537
|
-
* //-
|
|
538
|
-
* database.createTable(schema)
|
|
539
|
-
* .then(function(data) {
|
|
540
|
-
* const table = data[0];
|
|
541
|
-
* const operation = data[1];
|
|
542
|
-
*
|
|
543
|
-
* return operation.promise();
|
|
544
|
-
* })
|
|
545
|
-
* .then(function() {
|
|
546
|
-
* // Table created successfully.
|
|
547
|
-
* });
|
|
548
|
-
* ```
|
|
549
|
-
*/
|
|
550
|
-
createTable(schema: Schema, gaxOptions?: CallOptions): Promise<CreateTableResponse>;
|
|
551
|
-
createTable(schema: Schema, callback: CreateTableCallback): void;
|
|
552
|
-
createTable(schema: Schema, gaxOptions: CallOptions, callback: CreateTableCallback): void;
|
|
553
|
-
/**
|
|
554
|
-
* Decorates transaction so that when end() is called it will return the session
|
|
555
|
-
* back into the pool.
|
|
556
|
-
*
|
|
557
|
-
* @private
|
|
558
|
-
*
|
|
559
|
-
* @param {Session} session The session to release.
|
|
560
|
-
* @param {Transaction} transaction The transaction to observe.
|
|
561
|
-
* @returns {Transaction}
|
|
562
|
-
*/
|
|
563
|
-
private _releaseOnEnd;
|
|
564
|
-
/**
|
|
565
|
-
* @typedef {array} DatabaseDeleteResponse
|
|
566
|
-
* @property {object} 0 The full API response.
|
|
567
|
-
*/
|
|
568
|
-
/**
|
|
569
|
-
* @callback DatabaseDeleteCallback
|
|
570
|
-
* @param {?Error} err Request error, if any.
|
|
571
|
-
* @param {object} apiResponse The full API response.
|
|
572
|
-
*/
|
|
573
|
-
/**
|
|
574
|
-
* Delete the database.
|
|
575
|
-
*
|
|
576
|
-
* Wrapper around {@link v1.DatabaseAdminClient#dropDatabase}.
|
|
577
|
-
*
|
|
578
|
-
* @see {@link v1.DatabaseAdminClient#dropDatabase}
|
|
579
|
-
* @see [DropDatabase API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase)
|
|
580
|
-
*
|
|
581
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
582
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
583
|
-
* for more details.
|
|
584
|
-
* @param {DatabaseDeleteCallback} [callback] Callback function.
|
|
585
|
-
* @returns {Promise<DatabaseDeleteResponse>}
|
|
586
|
-
*
|
|
587
|
-
* @example
|
|
588
|
-
* ```
|
|
589
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
590
|
-
* const spanner = new Spanner();
|
|
591
|
-
*
|
|
592
|
-
* const instance = spanner.instance('my-instance');
|
|
593
|
-
* const database = instance.database('my-database');
|
|
594
|
-
*
|
|
595
|
-
* database.delete(function(err, apiResponse) {
|
|
596
|
-
* if (err) {
|
|
597
|
-
* // Error handling omitted.
|
|
598
|
-
* }
|
|
599
|
-
*
|
|
600
|
-
* // Database was deleted successfully.
|
|
601
|
-
* });
|
|
602
|
-
*
|
|
603
|
-
* //-
|
|
604
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
605
|
-
* //-
|
|
606
|
-
* database.delete().then(function(data) {
|
|
607
|
-
* const apiResponse = data[0];
|
|
608
|
-
* });
|
|
609
|
-
* ```
|
|
610
|
-
*/
|
|
611
|
-
delete(gaxOptions?: CallOptions): Promise<DatabaseDeleteResponse>;
|
|
612
|
-
delete(callback: DatabaseDeleteCallback): void;
|
|
613
|
-
delete(gaxOptions: CallOptions, callback: DatabaseDeleteCallback): void;
|
|
614
|
-
/**
|
|
615
|
-
* @typedef {array} DatabaseExistsResponse
|
|
616
|
-
* @property {boolean} 0 Whether the {@link Database} exists.
|
|
617
|
-
*/
|
|
618
|
-
/**
|
|
619
|
-
* @callback DatabaseExistsCallback
|
|
620
|
-
* @param {?Error} err Request error, if any.
|
|
621
|
-
* @param {boolean} exists Whether the {@link Database} exists.
|
|
622
|
-
*/
|
|
623
|
-
/**
|
|
624
|
-
* Check if a database exists.
|
|
625
|
-
*
|
|
626
|
-
* @method Database#exists
|
|
627
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
628
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
629
|
-
* for more details.
|
|
630
|
-
* @param {DatabaseExistsCallback} [callback] Callback function.
|
|
631
|
-
* @returns {Promise<DatabaseExistsResponse>}
|
|
632
|
-
*
|
|
633
|
-
* @example
|
|
634
|
-
* ```
|
|
635
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
636
|
-
* const spanner = new Spanner();
|
|
637
|
-
*
|
|
638
|
-
* const instance = spanner.instance('my-instance');
|
|
639
|
-
* const database = instance.database('my-database');
|
|
640
|
-
*
|
|
641
|
-
* database.exists(function(err, exists) {});
|
|
642
|
-
*
|
|
643
|
-
* //-
|
|
644
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
645
|
-
* //-
|
|
646
|
-
* database.exists().then(function(data) {
|
|
647
|
-
* const exists = data[0];
|
|
648
|
-
* });
|
|
649
|
-
* ```
|
|
650
|
-
*/
|
|
651
|
-
exists(gaxOptions?: CallOptions): Promise<[boolean]>;
|
|
652
|
-
exists(callback: ExistsCallback): void;
|
|
653
|
-
exists(gaxOptions: CallOptions, callback: ExistsCallback): void;
|
|
654
|
-
/**
|
|
655
|
-
* @typedef {array} GetDatabaseResponse
|
|
656
|
-
* @property {Database} 0 The {@link Database}.
|
|
657
|
-
* @property {object} 1 The full API response.
|
|
658
|
-
*/
|
|
659
|
-
/**
|
|
660
|
-
* @callback GetDatabaseCallback
|
|
661
|
-
* @param {?Error} err Request error, if any.
|
|
662
|
-
* @param {Database} database The {@link Database}.
|
|
663
|
-
* @param {object} apiResponse The full API response.
|
|
664
|
-
*/
|
|
665
|
-
/**
|
|
666
|
-
* Get a database if it exists.
|
|
667
|
-
*
|
|
668
|
-
* You may optionally use this to "get or create" an object by providing an
|
|
669
|
-
* object with `autoCreate` set to `true`. Any extra configuration that is
|
|
670
|
-
* normally required for the `create` method must be contained within this
|
|
671
|
-
* object as well.
|
|
672
|
-
*
|
|
673
|
-
* @param {options} [options] Configuration object.
|
|
674
|
-
* @param {boolean} [options.autoCreate=false] Automatically create the
|
|
675
|
-
* object if it does not exist.
|
|
676
|
-
* @param {object} [options.gaxOptions] Request configuration options,
|
|
677
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
678
|
-
* for more details.
|
|
679
|
-
* @param {GetDatabaseCallback} [callback] Callback function.
|
|
680
|
-
* @returns {Promise<GetDatabaseResponse>}
|
|
681
|
-
*
|
|
682
|
-
* @example
|
|
683
|
-
* ```
|
|
684
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
685
|
-
* const spanner = new Spanner();
|
|
686
|
-
*
|
|
687
|
-
* const instance = spanner.instance('my-instance');
|
|
688
|
-
* const database = instance.database('my-database');
|
|
689
|
-
*
|
|
690
|
-
* database.get(function(err, database, apiResponse) {
|
|
691
|
-
* // `database.metadata` has been populated.
|
|
692
|
-
* });
|
|
693
|
-
*
|
|
694
|
-
* //-
|
|
695
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
696
|
-
* //-
|
|
697
|
-
* database.get().then(function(data) {
|
|
698
|
-
* const database = data[0];
|
|
699
|
-
* const apiResponse = data[0];
|
|
700
|
-
* });
|
|
701
|
-
* ```
|
|
702
|
-
*/
|
|
703
|
-
get(options?: GetDatabaseConfig): Promise<DatabaseResponse>;
|
|
704
|
-
get(callback: DatabaseCallback): void;
|
|
705
|
-
get(options: GetDatabaseConfig, callback: DatabaseCallback): void;
|
|
706
|
-
/**
|
|
707
|
-
* @typedef {array} GetDatabaseMetadataResponse
|
|
708
|
-
* @property {object} 0 The {@link Database} metadata.
|
|
709
|
-
* @property {object} 1 The full API response.
|
|
710
|
-
*/
|
|
711
|
-
/**
|
|
712
|
-
* @callback GetDatabaseMetadataCallback
|
|
713
|
-
* @param {?Error} err Request error, if any.
|
|
714
|
-
* @param {object} metadata The {@link Database} metadata.
|
|
715
|
-
* @param {object} apiResponse The full API response.
|
|
716
|
-
*/
|
|
717
|
-
/**
|
|
718
|
-
* Get the database's metadata.
|
|
719
|
-
*
|
|
720
|
-
* Wrapper around {@link v1.DatabaseAdminClient#getDatabase}.
|
|
721
|
-
*
|
|
722
|
-
* @see {@link v1.DatabaseAdminClient#getDatabase}
|
|
723
|
-
* @see [GetDatabase API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase)
|
|
724
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
725
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
726
|
-
* for more details.
|
|
727
|
-
* @param {GetDatabaseMetadataCallback} [callback] Callback function.
|
|
728
|
-
* @returns {Promise<GetDatabaseMetadataResponse>}
|
|
729
|
-
*
|
|
730
|
-
* @example
|
|
731
|
-
* ```
|
|
732
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
733
|
-
* const spanner = new Spanner();
|
|
734
|
-
*
|
|
735
|
-
* const instance = spanner.instance('my-instance');
|
|
736
|
-
* const database = instance.database('my-database');
|
|
737
|
-
*
|
|
738
|
-
* database.getMetadata(function(err, metadata) {
|
|
739
|
-
* if (err) {
|
|
740
|
-
* // Error handling omitted.
|
|
741
|
-
* }
|
|
742
|
-
*
|
|
743
|
-
* // Database was deleted successfully.
|
|
744
|
-
* });
|
|
745
|
-
*
|
|
746
|
-
* //-
|
|
747
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
748
|
-
* //-
|
|
749
|
-
* database.getMetadata().then(function(data) {
|
|
750
|
-
* const metadata = data[0];
|
|
751
|
-
* const apiResponse = data[1];
|
|
752
|
-
* });
|
|
753
|
-
* ```
|
|
754
|
-
*/
|
|
755
|
-
getMetadata(gaxOptions?: CallOptions): Promise<GetDatabaseMetadataResponse>;
|
|
756
|
-
getMetadata(callback: GetDatabaseMetadataCallback): void;
|
|
757
|
-
getMetadata(gaxOptions: CallOptions, callback: GetDatabaseMetadataCallback): void;
|
|
758
|
-
/**
|
|
759
|
-
* {@link google.spanner.admin.database.v1#RestoreInfo} structure with restore
|
|
760
|
-
* source type enum translated to string form.
|
|
761
|
-
*
|
|
762
|
-
* @typedef {object} IRestoreInfoTranslatedEnum
|
|
763
|
-
*/
|
|
764
|
-
/**
|
|
765
|
-
* @callback GetRestoreInfoCallback
|
|
766
|
-
* @param {?Error} err Request error, if any.
|
|
767
|
-
* @param {IRestoreInfoTranslatedEnum | undefined} restoreInfo Contains the restore
|
|
768
|
-
* information for the database if it was restored from a backup.
|
|
769
|
-
*/
|
|
770
|
-
/**
|
|
771
|
-
* Retrieves the restore information of the database.
|
|
772
|
-
*
|
|
773
|
-
* @see {@link #getMetadata}
|
|
774
|
-
*
|
|
775
|
-
* @method Database#getRestoreInfo
|
|
776
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
777
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
778
|
-
* for more details.
|
|
779
|
-
* @param {GetRestoreInfoCallback} [callback] Callback function.
|
|
780
|
-
* @returns {Promise<IRestoreInfoTranslatedEnum | undefined>} When resolved,
|
|
781
|
-
* contains the restore information for the database if it was restored
|
|
782
|
-
* from a backup.
|
|
783
|
-
*
|
|
784
|
-
* @example
|
|
785
|
-
* ```
|
|
786
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
787
|
-
* const spanner = new Spanner();
|
|
788
|
-
* const instance = spanner.instance('my-instance');
|
|
789
|
-
* const database = instance.database('my-database');
|
|
790
|
-
* const restoreInfo = await database.getRestoreInfo();
|
|
791
|
-
* console.log(`Database restored from ${restoreInfo.backupInfo.backup}`);
|
|
792
|
-
* ```
|
|
793
|
-
*/
|
|
794
|
-
getRestoreInfo(options?: CallOptions): Promise<IRestoreInfoTranslatedEnum | undefined>;
|
|
795
|
-
getRestoreInfo(callback: GetRestoreInfoCallback): void;
|
|
796
|
-
getRestoreInfo(options: CallOptions, callback: GetRestoreInfoCallback): void;
|
|
797
|
-
/**
|
|
798
|
-
* @callback GetStateCallback
|
|
799
|
-
* @param {?Error} err Request error, if any.
|
|
800
|
-
* @param {EnumKey<typeof, google.spanner.admin.database.v1.Database.State> | undefined} state
|
|
801
|
-
* Contains the current state of the database if the state is defined.
|
|
802
|
-
*/
|
|
803
|
-
/**
|
|
804
|
-
* Retrieves the state of the database.
|
|
805
|
-
*
|
|
806
|
-
* The database state indicates if the database is ready after creation or
|
|
807
|
-
* after being restored from a backup.
|
|
808
|
-
*
|
|
809
|
-
* @see {@link #getMetadata}
|
|
810
|
-
*
|
|
811
|
-
* @method Database#getState
|
|
812
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
813
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
814
|
-
* for more details.
|
|
815
|
-
* @param {GetStateCallback} [callback] Callback function.
|
|
816
|
-
* @returns {Promise<EnumKey<typeof, google.spanner.admin.database.v1.Database.State> | undefined>}
|
|
817
|
-
* When resolved, contains the current state of the database if the state
|
|
818
|
-
* is defined.
|
|
819
|
-
*
|
|
820
|
-
* @example
|
|
821
|
-
* ```
|
|
822
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
823
|
-
* const spanner = new Spanner();
|
|
824
|
-
* const instance = spanner.instance('my-instance');
|
|
825
|
-
* const database = instance.database('my-database');
|
|
826
|
-
* const state = await database.getState();
|
|
827
|
-
* const isReady = (state === 'READY');
|
|
828
|
-
* ```
|
|
829
|
-
*/
|
|
830
|
-
getState(options?: CallOptions): Promise<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Database.State> | undefined>;
|
|
831
|
-
getState(callback: GetStateCallback): void;
|
|
832
|
-
getState(options: CallOptions, callback: GetStateCallback): void;
|
|
833
|
-
/**
|
|
834
|
-
* Retrieves the dialect of the database
|
|
835
|
-
*
|
|
836
|
-
* @see {@link #getMetadata}
|
|
837
|
-
*
|
|
838
|
-
* @method Database#getDatabaseDialect
|
|
839
|
-
*
|
|
840
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
841
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
842
|
-
* for more details.
|
|
843
|
-
* @param {GetDatabaseDialectCallback} [callback] Callback function.
|
|
844
|
-
* @returns {Promise<EnumKey<typeof, databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | undefined>}
|
|
845
|
-
* When resolved, contains the database dialect of the database if the dialect is defined.
|
|
846
|
-
* @example
|
|
847
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
848
|
-
* const spanner = new Spanner();
|
|
849
|
-
* const instance = spanner.instance('my-instance');
|
|
850
|
-
* const database = instance.database('my-database');
|
|
851
|
-
* const dialect = await database.getDatabaseDialect();
|
|
852
|
-
* const isGoogleSQL = (dialect === 'GOOGLE_STANDARD_SQL');
|
|
853
|
-
* const isPostgreSQL = (dialect === 'POSTGRESQL');
|
|
854
|
-
*/
|
|
855
|
-
getDatabaseDialect(options?: CallOptions): Promise<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | undefined>;
|
|
856
|
-
getDatabaseDialect(callback: GetDatabaseDialectCallback): void;
|
|
857
|
-
getDatabaseDialect(options: CallOptions, callback: GetDatabaseDialectCallback): void;
|
|
858
|
-
/**
|
|
859
|
-
* @typedef {array} GetSchemaResponse
|
|
860
|
-
* @property {string[]} 0 An array of database DDL statements.
|
|
861
|
-
* @property {object} 1 The full API response.
|
|
862
|
-
*/
|
|
863
|
-
/**
|
|
864
|
-
* @callback GetSchemaCallback
|
|
865
|
-
* @param {?Error} err Request error, if any.
|
|
866
|
-
* @param {string[]} statements An array of database DDL statements.
|
|
867
|
-
* @param {object} apiResponse The full API response.
|
|
868
|
-
*/
|
|
869
|
-
/**
|
|
870
|
-
* Get this database's schema as a list of formatted DDL statements.
|
|
871
|
-
*
|
|
872
|
-
* Wrapper around {@link v1.DatabaseAdminClient#getDatabaseDdl}.
|
|
873
|
-
*
|
|
874
|
-
* @see {@link v1.DatabaseAdminClient#getDatabaseDdl}
|
|
875
|
-
* @see [Data Definition Language (DDL)](https://cloud.google.com/spanner/docs/data-definition-language)
|
|
876
|
-
* @see [GetDatabaseDdl API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl)
|
|
877
|
-
*
|
|
878
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
879
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
880
|
-
* for more details.
|
|
881
|
-
* @param {GetSchemaCallback} [callback] Callback function.
|
|
882
|
-
* @returns {Promise<GetSchemaResponse>}
|
|
883
|
-
*
|
|
884
|
-
* @example
|
|
885
|
-
* ```
|
|
886
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
887
|
-
* const spanner = new Spanner();
|
|
888
|
-
*
|
|
889
|
-
* const instance = spanner.instance('my-instance');
|
|
890
|
-
* const database = instance.database('my-database');
|
|
891
|
-
*
|
|
892
|
-
* database.getSchema(function(err, statements, apiResponse) {});
|
|
893
|
-
*
|
|
894
|
-
* //-
|
|
895
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
896
|
-
* //-
|
|
897
|
-
* database.getSchema().then(function(data) {
|
|
898
|
-
* const statements = data[0];
|
|
899
|
-
* const apiResponse = data[1];
|
|
900
|
-
* });
|
|
901
|
-
* ```
|
|
902
|
-
*/
|
|
903
|
-
getSchema(options?: CallOptions): Promise<GetSchemaResponse>;
|
|
904
|
-
getSchema(callback: GetSchemaCallback): void;
|
|
905
|
-
getSchema(options: CallOptions, callback: GetSchemaCallback): void;
|
|
906
|
-
/**
|
|
907
|
-
* Options object for requested policy version.
|
|
908
|
-
*
|
|
909
|
-
* @typedef {object} GetIamPolicyOptions
|
|
910
|
-
* @property {number|null} [requestedPolicyVersion] policy version requested, possible values are 0, 1 and 3,
|
|
911
|
-
* See {@link https://cloud.google.com/iam/docs/policies#versions} for more details
|
|
912
|
-
* @property {object} [gaxOptions] Request configuration options,
|
|
913
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
914
|
-
* for more details.
|
|
915
|
-
*/
|
|
916
|
-
/**
|
|
917
|
-
* @callback GetIamPolicyCallback
|
|
918
|
-
* @param {?Error} err Request error, if any.
|
|
919
|
-
* @param {google.iam.v1.Policy| undefined} policy Returns policy for the give database
|
|
920
|
-
*/
|
|
921
|
-
/**
|
|
922
|
-
* Retrieves the policy of the database.
|
|
923
|
-
*
|
|
924
|
-
* A Policy is a collection of bindings. A binding binds one or more members, or principals,
|
|
925
|
-
* to a single role. Principals can be user accounts, service accounts, Google groups, and
|
|
926
|
-
* domains (such as G Suite). A role is a named list of permissions; each role can be an IAM
|
|
927
|
-
* predefined role or a user-created custom role.
|
|
928
|
-
*
|
|
929
|
-
* @see {@link #getIamPolicy}
|
|
930
|
-
*
|
|
931
|
-
* @method Database#getIamPolicy
|
|
932
|
-
* @param {object} [options] requestedPolicyVersion and gax options(configuration options)
|
|
933
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
|
|
934
|
-
* for more details on gax options.
|
|
935
|
-
* @param {GetIamPolicyCallback} [callback] Callback function.
|
|
936
|
-
* @returns {Promise<Policy | undefined>}
|
|
937
|
-
* When resolved, contains the current policy of the database.
|
|
938
|
-
*
|
|
939
|
-
* @example
|
|
940
|
-
* ```
|
|
941
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
942
|
-
* const spanner = new Spanner();
|
|
943
|
-
* const instance = spanner.instance('my-instance');
|
|
944
|
-
* const database = instance.database('my-database');
|
|
945
|
-
* const policy = await database.getIamPolicy();
|
|
946
|
-
* console.log(policy.bindings, policy.version, policy.etag, policy.auditConfigs)
|
|
947
|
-
* const policyWithVersion specified = await database.getIamPolicy({requestedPolicyVersion: 3});
|
|
948
|
-
* ```
|
|
949
|
-
*/
|
|
950
|
-
getIamPolicy(options?: GetIamPolicyOptions): Promise<GetIamPolicyResponse>;
|
|
951
|
-
getIamPolicy(callback: GetIamPolicyCallback): void;
|
|
952
|
-
getIamPolicy(options: GetIamPolicyOptions, callback: GetIamPolicyCallback): void;
|
|
953
|
-
/**
|
|
954
|
-
* Options object for listing sessions.
|
|
955
|
-
*
|
|
956
|
-
* @typedef {object} GetSessionsOptions
|
|
957
|
-
* @property {string} [filter] An expression for filtering the results of the
|
|
958
|
-
* request. Filter rules are case insensitive. The fields eligible for
|
|
959
|
-
* filtering are:
|
|
960
|
-
* - **`name`**
|
|
961
|
-
* - **`display_name`**
|
|
962
|
-
* - **`labels.key`** where key is the name of a label
|
|
963
|
-
*
|
|
964
|
-
* Some examples of using filters are:
|
|
965
|
-
* - **`name:*`** The instance has a name.
|
|
966
|
-
* - **`name:Howl`** The instance's name is howl.
|
|
967
|
-
* - **`labels.env:*`** The instance has the label env.
|
|
968
|
-
* - **`labels.env:dev`** The instance's label env has the value dev.
|
|
969
|
-
* - **`name:howl labels.env:dev`** The instance's name is howl and it has
|
|
970
|
-
* the label env with value dev.
|
|
971
|
-
* @property {number} [pageSize] Maximum number of results per page.
|
|
972
|
-
* @property {string} [pageToken] A previously-returned page token
|
|
973
|
-
* representing part of the larger set of results to view.
|
|
974
|
-
* @property {object} [gaxOptions] Request configuration options,
|
|
975
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
976
|
-
* for more details.
|
|
977
|
-
*/
|
|
978
|
-
/**
|
|
979
|
-
* @typedef {array} GetSessionsResponse
|
|
980
|
-
* @property {Session[]} 0 Array of {@link Session} instances.
|
|
981
|
-
* @property {object} 1 A query object to receive more results.
|
|
982
|
-
* @property {object} 2 The full API response.
|
|
983
|
-
*/
|
|
984
|
-
/**
|
|
985
|
-
* @callback GetSessionsCallback
|
|
986
|
-
* @param {?Error} err Request error, if any.
|
|
987
|
-
* @param {Session[]} instances Array of {@link Session} instances.
|
|
988
|
-
* @param {object} nextQuery A query object to receive more results.
|
|
989
|
-
* @param {object} apiResponse The full API response.
|
|
990
|
-
*/
|
|
991
|
-
/**
|
|
992
|
-
* Gets a list of sessions.
|
|
993
|
-
*
|
|
994
|
-
* Wrapper around {@link v1.SpannerClient#listSessions}
|
|
995
|
-
*
|
|
996
|
-
* @see {@link v1.SpannerClient#listSessions}
|
|
997
|
-
* @see [ListSessions API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ListSessions)
|
|
998
|
-
*
|
|
999
|
-
* @param {GetSessionsOptions} [options] Options object for listing sessions.
|
|
1000
|
-
* @param {GetSessionsCallback} [callback] Callback function.
|
|
1001
|
-
* @returns {Promise<GetSessionsResponse>}
|
|
1002
|
-
*
|
|
1003
|
-
* @example
|
|
1004
|
-
* ```
|
|
1005
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1006
|
-
* const spanner = new Spanner();
|
|
1007
|
-
*
|
|
1008
|
-
* const instance = spanner.instance('my-instance');
|
|
1009
|
-
* const database = instance.database('my-database');
|
|
1010
|
-
*
|
|
1011
|
-
* database.getSessions(function(err, sessions) {
|
|
1012
|
-
* // `sessions` is an array of `Session` objects.
|
|
1013
|
-
* });
|
|
1014
|
-
*
|
|
1015
|
-
* //-
|
|
1016
|
-
* // To control how many API requests are made and page through the results
|
|
1017
|
-
* // manually, set `autoPaginate` to `false`.
|
|
1018
|
-
* //-
|
|
1019
|
-
* function callback(err, sessions, nextQuery, apiResponse) {
|
|
1020
|
-
* if (nextQuery) {
|
|
1021
|
-
* // More results exist.
|
|
1022
|
-
* database.getSessions(nextQuery, callback);
|
|
1023
|
-
* }
|
|
1024
|
-
* }
|
|
1025
|
-
*
|
|
1026
|
-
* database.getInstances({
|
|
1027
|
-
* gaxOptions: {autoPaginate: false}
|
|
1028
|
-
* }, callback);
|
|
1029
|
-
*
|
|
1030
|
-
* //-
|
|
1031
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
1032
|
-
* //-
|
|
1033
|
-
* database.getInstances().then(function(data) {
|
|
1034
|
-
* const sessions = data[0];
|
|
1035
|
-
* });
|
|
1036
|
-
* ```
|
|
1037
|
-
*/
|
|
1038
|
-
getSessions(options?: GetSessionsOptions): Promise<GetSessionsResponse>;
|
|
1039
|
-
getSessions(callback: GetSessionsCallback): void;
|
|
1040
|
-
getSessions(options: GetSessionsOptions, callback: GetSessionsCallback): void;
|
|
1041
|
-
/**
|
|
1042
|
-
* Get a list of sessions as a readable object stream.
|
|
1043
|
-
*
|
|
1044
|
-
* Wrapper around {@link v1.SpannerClient#listSessions}
|
|
1045
|
-
*
|
|
1046
|
-
* @see {@link v1.SpannerClient#listSessions}
|
|
1047
|
-
* @see [ListSessions API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ListSessions)
|
|
1048
|
-
*
|
|
1049
|
-
* @method Spanner#getSessionsStream
|
|
1050
|
-
* @param {GetSessionsOptions} [options] Options object for listing sessions.
|
|
1051
|
-
* @returns {ReadableStream} A readable stream that emits {@link Session}
|
|
1052
|
-
* instances.
|
|
1053
|
-
*
|
|
1054
|
-
* @example
|
|
1055
|
-
* ```
|
|
1056
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1057
|
-
* const spanner = new Spanner();
|
|
1058
|
-
*
|
|
1059
|
-
* const instance = spanner.instance('my-instance');
|
|
1060
|
-
* const database = instance.database('my-database');
|
|
1061
|
-
*
|
|
1062
|
-
* database.getSessionsStream()
|
|
1063
|
-
* .on('error', console.error)
|
|
1064
|
-
* .on('data', function(database) {
|
|
1065
|
-
* // `sessions` is a `Session` object.
|
|
1066
|
-
* })
|
|
1067
|
-
* .on('end', function() {
|
|
1068
|
-
* // All sessions retrieved.
|
|
1069
|
-
* });
|
|
1070
|
-
*
|
|
1071
|
-
* //-
|
|
1072
|
-
* // If you anticipate many results, you can end a stream early to prevent
|
|
1073
|
-
* // unnecessary processing and API requests.
|
|
1074
|
-
* //-
|
|
1075
|
-
* database.getSessionsStream()
|
|
1076
|
-
* .on('data', function(session) {
|
|
1077
|
-
* this.end();
|
|
1078
|
-
* });
|
|
1079
|
-
* ```
|
|
1080
|
-
*/
|
|
1081
|
-
getSessionsStream(options?: GetSessionsOptions): NodeJS.ReadableStream;
|
|
1082
|
-
/**
|
|
1083
|
-
* @typedef {array} GetSnapshotResponse
|
|
1084
|
-
* @property {Snapshot} 0 The snapshot object.
|
|
1085
|
-
*/
|
|
1086
|
-
/**
|
|
1087
|
-
* @callback GetSnapshotCallback
|
|
1088
|
-
* @param {?Error} err Request error, if any.
|
|
1089
|
-
* @param {Snapshot} snapshot The snapshot object.
|
|
1090
|
-
*/
|
|
1091
|
-
/**
|
|
1092
|
-
* Get a read only {@link Snapshot} transaction.
|
|
1093
|
-
*
|
|
1094
|
-
* Wrapper around {@link v1.SpannerClient#beginTransaction}.
|
|
1095
|
-
*
|
|
1096
|
-
* **NOTE:** When finished with the Snapshot, {@link Snapshot#end} should be
|
|
1097
|
-
* called to release the underlying {@link Session}. **Failure to do could
|
|
1098
|
-
* result in a Session leak.**
|
|
1099
|
-
*
|
|
1100
|
-
* **NOTE:** Since the returned {@link Snapshot} transaction is not a
|
|
1101
|
-
* single-use transaction, it is invalid to set the `minReadTimestamp` and
|
|
1102
|
-
* `maxStaleness` parameters in {@link TimestampBounds} as those parameters
|
|
1103
|
-
* can only be set for single-use transactions.
|
|
1104
|
-
* https://cloud.google.com/spanner/docs/reference/rest/v1/TransactionOptions#bounded-staleness
|
|
1105
|
-
*
|
|
1106
|
-
* @see {@link v1.SpannerClient#beginTransaction}
|
|
1107
|
-
*
|
|
1108
|
-
* @param {TimestampBounds} [options] Timestamp bounds.
|
|
1109
|
-
* @param {GetSnapshotCallback} [callback] Callback function.
|
|
1110
|
-
* @returns {Promise<GetSnapshotResponse>}
|
|
1111
|
-
*
|
|
1112
|
-
* @example
|
|
1113
|
-
* ```
|
|
1114
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1115
|
-
* const spanner = new Spanner();
|
|
1116
|
-
*
|
|
1117
|
-
* const instance = spanner.instance('my-instance');
|
|
1118
|
-
* const database = instance.database('my-database');
|
|
1119
|
-
*
|
|
1120
|
-
* database.getSnapshot(function(err, transaction) {
|
|
1121
|
-
* if (err) {
|
|
1122
|
-
* // Error handling omitted.
|
|
1123
|
-
* }
|
|
1124
|
-
*
|
|
1125
|
-
* // Should be called when finished with Snapshot.
|
|
1126
|
-
* transaction.end();
|
|
1127
|
-
* });
|
|
1128
|
-
* ```
|
|
1129
|
-
*
|
|
1130
|
-
* @example If the callback is omitted, we'll return a Promise.
|
|
1131
|
-
* ```
|
|
1132
|
-
* database.getSnapshot().then(function(data) {
|
|
1133
|
-
* const transaction = data[0];
|
|
1134
|
-
* });
|
|
1135
|
-
* ```
|
|
1136
|
-
*
|
|
1137
|
-
* @example <caption>include:samples/transaction.js</caption>
|
|
1138
|
-
* region_tag:spanner_read_only_transaction
|
|
1139
|
-
* Read-only transaction:
|
|
1140
|
-
*/
|
|
1141
|
-
getSnapshot(options?: TimestampBounds): Promise<[Snapshot]>;
|
|
1142
|
-
getSnapshot(callback: GetSnapshotCallback): void;
|
|
1143
|
-
getSnapshot(options: TimestampBounds, callback: GetSnapshotCallback): void;
|
|
1144
|
-
/**
|
|
1145
|
-
* @typedef {array} GetTransactionResponse
|
|
1146
|
-
* @property {Transaction} 0 The transaction object.
|
|
1147
|
-
*/
|
|
1148
|
-
/**
|
|
1149
|
-
* @callback GetTransactionCallback
|
|
1150
|
-
* @param {?Error} err Request error, if any.
|
|
1151
|
-
* @param {Transaction} transaction The transaction object.
|
|
1152
|
-
*/
|
|
1153
|
-
/**
|
|
1154
|
-
* Get a read/write ready {@link Transaction} object.
|
|
1155
|
-
*
|
|
1156
|
-
* **NOTE:** In the event that you encounter an error while reading/writing,
|
|
1157
|
-
* if you decide to forgo calling {@link Transaction#commit} or
|
|
1158
|
-
* {@link Transaction#rollback}, then you need to call
|
|
1159
|
-
* {@link Transaction#end} to release the underlying {@link Session} object.
|
|
1160
|
-
* **Failure to do could result in a Session leak.**
|
|
1161
|
-
*
|
|
1162
|
-
* Wrapper around {@link v1.SpannerClient#beginTransaction}.
|
|
1163
|
-
*
|
|
1164
|
-
* @see {@link v1.SpannerClient#beginTransaction}
|
|
1165
|
-
*
|
|
1166
|
-
* @param {GetTransactionCallback} [callback] Callback function.
|
|
1167
|
-
* @returns {Promise<GetTransactionResponse>}
|
|
1168
|
-
*
|
|
1169
|
-
* @example
|
|
1170
|
-
* ```
|
|
1171
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1172
|
-
* const spanner = new Spanner();
|
|
1173
|
-
*
|
|
1174
|
-
* const instance = spanner.instance('my-instance');
|
|
1175
|
-
* const database = instance.database('my-database');
|
|
1176
|
-
*
|
|
1177
|
-
* database.getTransaction(function(err, transaction) {});
|
|
1178
|
-
*
|
|
1179
|
-
* ```
|
|
1180
|
-
* @example If the callback is omitted, we'll return a Promise.
|
|
1181
|
-
* ```
|
|
1182
|
-
* database.getTransaction().then(function(data) {
|
|
1183
|
-
* const transaction = data[0];
|
|
1184
|
-
* });
|
|
1185
|
-
* ```
|
|
1186
|
-
*/
|
|
1187
|
-
getTransaction(optionsOrCallback?: GetTransactionOptions): Promise<[Transaction]>;
|
|
1188
|
-
getTransaction(callback: GetTransactionCallback): void;
|
|
1189
|
-
/**
|
|
1190
|
-
* Query object for listing database operations.
|
|
1191
|
-
*
|
|
1192
|
-
* @typedef {object} GetDatabaseOperationsOptions
|
|
1193
|
-
* @property {string} [filter] An expression for filtering the results of the
|
|
1194
|
-
* request. Filter can be configured as outlined in
|
|
1195
|
-
* {@link v1.DatabaseAdminClient#listDatabaseOperations}.
|
|
1196
|
-
* @property {number} [pageSize] Maximum number of results per page.
|
|
1197
|
-
* @property {string} [pageToken] A previously-returned page token
|
|
1198
|
-
* representing part of the larger set of results to view.
|
|
1199
|
-
* @property {object} [gaxOptions] Request configuration options,
|
|
1200
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
1201
|
-
* for more details.
|
|
1202
|
-
* @param {GetDatabaseOperationsCallback} [callback] Callback function.
|
|
1203
|
-
*/
|
|
1204
|
-
/**
|
|
1205
|
-
* @typedef {array} GetDatabaseOperationsResponse
|
|
1206
|
-
* @property {IOperation[]} 0 Array of {@link IOperation} instances.
|
|
1207
|
-
* @property {object} 1 The full API response.
|
|
1208
|
-
*/
|
|
1209
|
-
/**
|
|
1210
|
-
* List pending and completed operations for the database.
|
|
1211
|
-
*
|
|
1212
|
-
* @see {@link Instance.getDatabaseOperations}
|
|
1213
|
-
*
|
|
1214
|
-
* @param {GetDatabaseOperationsOptions} [options] Contains query object for
|
|
1215
|
-
* listing database operations and request configuration options,
|
|
1216
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
1217
|
-
* for more details.
|
|
1218
|
-
* @returns {Promise<GetDatabaseOperationsResponse>} When resolved, contains
|
|
1219
|
-
* a paged list of database operations.
|
|
1220
|
-
*
|
|
1221
|
-
* @example
|
|
1222
|
-
* ```
|
|
1223
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1224
|
-
* const spanner = new Spanner();
|
|
1225
|
-
* const instance = spanner.instance('my-instance');
|
|
1226
|
-
* const database = instance.database('my-database');
|
|
1227
|
-
* const [operations] = await database.getOperations();
|
|
1228
|
-
*
|
|
1229
|
-
* //-
|
|
1230
|
-
* // To manually handle pagination, set autoPaginate:false in gaxOptions.
|
|
1231
|
-
* //-
|
|
1232
|
-
* let pageToken = undefined;
|
|
1233
|
-
* do {
|
|
1234
|
-
* const [operations, , response] = await database.getOperations({
|
|
1235
|
-
* pageSize: 3,
|
|
1236
|
-
* pageToken,
|
|
1237
|
-
* gaxOptions: {autoPaginate: false},
|
|
1238
|
-
* });
|
|
1239
|
-
* operations.forEach(operation => {
|
|
1240
|
-
* // Do something with operation
|
|
1241
|
-
* });
|
|
1242
|
-
* pageToken = response.nextPageToken;
|
|
1243
|
-
* } while (pageToken);
|
|
1244
|
-
* ```
|
|
1245
|
-
*/
|
|
1246
|
-
getOperations(options?: GetDatabaseOperationsOptions): Promise<GetDatabaseOperationsResponse>;
|
|
1247
|
-
getOperations(callback: GetDatabaseOperationsCallback): void;
|
|
1248
|
-
getOperations(options: GetDatabaseOperationsOptions, callback: GetDatabaseOperationsCallback): void;
|
|
1249
|
-
/**
|
|
1250
|
-
* @typedef {array} GetDatabaseRolesResponse
|
|
1251
|
-
* @property {IDatabaseRolees[]} 0 Array of list of database roles.
|
|
1252
|
-
* @property {object} 1 A query object to receive more results.
|
|
1253
|
-
* @property {object} 2 The full API response.
|
|
1254
|
-
*/
|
|
1255
|
-
/**
|
|
1256
|
-
* @callback GetDatabaseRolesCallback
|
|
1257
|
-
* @param {?Error} err Request error, if any.
|
|
1258
|
-
* @param {object} apiResponse The full API response.
|
|
1259
|
-
*/
|
|
1260
|
-
/**
|
|
1261
|
-
* Gets a list of database roles
|
|
1262
|
-
*
|
|
1263
|
-
* @see {@link v1.DatabaseAdminClient#getDatabaseRoles}
|
|
1264
|
-
* @see [GetDatabaseRoles API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseRoles)
|
|
1265
|
-
*
|
|
1266
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
1267
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
1268
|
-
* for more details.
|
|
1269
|
-
* @param {GetDatabaseRolesCallback} [callback] Callback function.
|
|
1270
|
-
* @returns {Promise<GetDatabaseRolesResponse>}
|
|
1271
|
-
*
|
|
1272
|
-
* @example
|
|
1273
|
-
* ```
|
|
1274
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1275
|
-
* const spanner = new Spanner();
|
|
1276
|
-
*
|
|
1277
|
-
* const instance = spanner.instance('my-instance');
|
|
1278
|
-
* const database = instance.database('my-database');
|
|
1279
|
-
*
|
|
1280
|
-
* database.getDatabaseRoles(function(err, roles) {
|
|
1281
|
-
* // `roles` is an array of `DatabaseRoles` objects.
|
|
1282
|
-
* });
|
|
1283
|
-
*
|
|
1284
|
-
* //-
|
|
1285
|
-
* // To control how many API requests are made and page through the results
|
|
1286
|
-
* // manually, set `autoPaginate` to `false`.
|
|
1287
|
-
* //-
|
|
1288
|
-
* function callback(err, roles, nextQuery, apiResponse) {
|
|
1289
|
-
* if (nextQuery) {
|
|
1290
|
-
* // More results exist.
|
|
1291
|
-
* database.getDatabaseRoles(nextQuery, callback);
|
|
1292
|
-
* }
|
|
1293
|
-
* }
|
|
1294
|
-
*
|
|
1295
|
-
* database.getInstances({
|
|
1296
|
-
* gaxOptions: {autoPaginate: false}
|
|
1297
|
-
* }, callback);
|
|
1298
|
-
*
|
|
1299
|
-
* //-
|
|
1300
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
1301
|
-
* //-
|
|
1302
|
-
* database.getInstances().then(function(data) {
|
|
1303
|
-
* const roles = data[0];
|
|
1304
|
-
* });
|
|
1305
|
-
* ```
|
|
1306
|
-
*/
|
|
1307
|
-
getDatabaseRoles(gaxOptions?: CallOptions): Promise<GetDatabaseRolesResponse>;
|
|
1308
|
-
getDatabaseRoles(callback: GetDatabaseRolesCallback): void;
|
|
1309
|
-
getDatabaseRoles(gaxOptions: CallOptions, callback: GetDatabaseRolesCallback): void;
|
|
1310
|
-
/**
|
|
1311
|
-
* Make an API request, first assuring an active session is used.
|
|
1312
|
-
*
|
|
1313
|
-
* @private
|
|
1314
|
-
*
|
|
1315
|
-
* @param {object} config Request config
|
|
1316
|
-
* @param {function} callback Callback function
|
|
1317
|
-
*/
|
|
1318
|
-
makePooledRequest_(config: RequestConfig): Promise<Session>;
|
|
1319
|
-
makePooledRequest_(config: RequestConfig, callback: PoolRequestCallback): void;
|
|
1320
|
-
/**
|
|
1321
|
-
* Make an API request as a stream, first assuring an active session is used.
|
|
1322
|
-
*
|
|
1323
|
-
* @private
|
|
1324
|
-
*
|
|
1325
|
-
* @param {object} config Request config
|
|
1326
|
-
* @returns {Stream}
|
|
1327
|
-
*/
|
|
1328
|
-
makePooledStreamingRequest_(config: RequestConfig): Readable;
|
|
1329
|
-
/**
|
|
1330
|
-
* @typedef {object} RestoreOptions
|
|
1331
|
-
* @property {google.spanner.admin.database.v1.IRestoreDatabaseEncryptionConfig}
|
|
1332
|
-
* encryptionConfig An encryption configuration describing
|
|
1333
|
-
* the encryption type and key resources in Cloud KMS used to
|
|
1334
|
-
* encrypt/decrypt the database to restore to.
|
|
1335
|
-
* @property {CallOptions} [gaxOptions] The request configuration options,
|
|
1336
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
1337
|
-
* for more details.
|
|
1338
|
-
*/
|
|
1339
|
-
/**
|
|
1340
|
-
* @typedef {array} RestoreDatabaseResponse
|
|
1341
|
-
* @property {Database} 0 The new {@link Database}.
|
|
1342
|
-
* @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
|
|
1343
|
-
* the status of the request.
|
|
1344
|
-
* @property {object} 2 The full API response.
|
|
1345
|
-
*/
|
|
1346
|
-
/**
|
|
1347
|
-
* @callback RestoreDatabaseCallback
|
|
1348
|
-
* @param {?Error} err Request error, if any.
|
|
1349
|
-
* @param {Database} database The new {@link Database}.
|
|
1350
|
-
* @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
|
|
1351
|
-
* check the status of the request.
|
|
1352
|
-
* @param {object} apiResponse The full API response.
|
|
1353
|
-
*/
|
|
1354
|
-
/**
|
|
1355
|
-
* Restore a backup into this database.
|
|
1356
|
-
*
|
|
1357
|
-
* When this call completes, the restore will have commenced but will not
|
|
1358
|
-
* necessarily have completed.
|
|
1359
|
-
*
|
|
1360
|
-
* @param {string} backupPath The path of the backup to restore.
|
|
1361
|
-
* @param {RestoreOptions} [options] Request configuration options.
|
|
1362
|
-
* @param {RestoreDatabaseCallback} [callback] Callback function.
|
|
1363
|
-
* @returns {Promise<RestoreDatabaseResponse>} When resolved, contains the restore operation.
|
|
1364
|
-
*
|
|
1365
|
-
* @example
|
|
1366
|
-
* ```
|
|
1367
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1368
|
-
* const spanner = new Spanner();
|
|
1369
|
-
* const instance = spanner.instance('my-instance');
|
|
1370
|
-
* const database = instance.database('my-database');
|
|
1371
|
-
* const backupName = 'projects/my-project/instances/my-instance/backups/my-backup';
|
|
1372
|
-
* const [, restoreOperation] = await database.restore(backupName);
|
|
1373
|
-
* // Wait for restore to complete
|
|
1374
|
-
* await restoreOperation.promise();
|
|
1375
|
-
*
|
|
1376
|
-
* //-
|
|
1377
|
-
* // Restore database with a different encryption key to the one used by the
|
|
1378
|
-
* // backup.
|
|
1379
|
-
* //-
|
|
1380
|
-
* const [, restoreWithKeyOperation] = await database.restore(
|
|
1381
|
-
* backupName,
|
|
1382
|
-
* {
|
|
1383
|
-
* encryptionConfig: {
|
|
1384
|
-
* encryptionType: 'CUSTOMER_MANAGED_ENCRYPTION',
|
|
1385
|
-
* kmsKeyName: 'projects/my-project-id/my-region/keyRings/my-key-ring/cryptoKeys/my-key',
|
|
1386
|
-
* }
|
|
1387
|
-
* },
|
|
1388
|
-
* );
|
|
1389
|
-
* // Wait for restore to complete
|
|
1390
|
-
* await restoreWithKeyOperation.promise();
|
|
1391
|
-
* ```
|
|
1392
|
-
*/
|
|
1393
|
-
restore(backupPath: string): Promise<RestoreDatabaseResponse>;
|
|
1394
|
-
restore(backupPath: string, options?: RestoreOptions | CallOptions): Promise<RestoreDatabaseResponse>;
|
|
1395
|
-
restore(backupPath: string, callback: RestoreDatabaseCallback): void;
|
|
1396
|
-
restore(backupPath: string, options: RestoreOptions | CallOptions, callback: RestoreDatabaseCallback): void;
|
|
1397
|
-
/**
|
|
1398
|
-
* Transaction options.
|
|
1399
|
-
*
|
|
1400
|
-
* @typedef {object} DatabaseRunRequest
|
|
1401
|
-
* @property {number} [exactStaleness] Executes all reads at the timestamp
|
|
1402
|
-
* that is `exactStaleness` old.
|
|
1403
|
-
* @property {date} [readTimestamp] Execute all reads at the given
|
|
1404
|
-
* timestamp.
|
|
1405
|
-
* @property {boolean} [strong] Read at the timestamp where all previously
|
|
1406
|
-
* committed transactions are visible.
|
|
1407
|
-
*/
|
|
1408
|
-
/**
|
|
1409
|
-
* @typedef {array} RunResponse
|
|
1410
|
-
* @property {Array<Row | Json>} 0 Rows are returned as an array objects. Each
|
|
1411
|
-
* object has a `name` and `value` property. To get a serialized object,
|
|
1412
|
-
* call `toJSON()`.
|
|
1413
|
-
* @property {?google.spanner.v1.IResultSetStats} 1 Query statistics, if the query is executed in
|
|
1414
|
-
* PLAN or PROFILE mode.
|
|
1415
|
-
*/
|
|
1416
|
-
/**
|
|
1417
|
-
* @callback RunCallback
|
|
1418
|
-
* @param {?Error} err Request error, if any.
|
|
1419
|
-
* @param {Array<Row | Json>} rows Rows are returned as an array of objects.
|
|
1420
|
-
* Each object has a `name` and `value` property. To get a serialized
|
|
1421
|
-
* object, call `toJSON()`.
|
|
1422
|
-
* @param {?google.spanner.v1.IResultSetStats} stats Query statistics, if the query is executed
|
|
1423
|
-
* in PLAN or PROFILE mode.
|
|
1424
|
-
*/
|
|
1425
|
-
/**
|
|
1426
|
-
* Execute a SQL statement on this database.
|
|
1427
|
-
*
|
|
1428
|
-
* Wrapper around {@link v1.SpannerClient#executeStreamingSql}.
|
|
1429
|
-
*
|
|
1430
|
-
* @see {@link v1.SpannerClient#executeStreamingSql}
|
|
1431
|
-
* @see [Query Syntax](https://cloud.google.com/spanner/docs/query-syntax)
|
|
1432
|
-
* @see [ExecuteSql API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ExecuteSql)
|
|
1433
|
-
*
|
|
1434
|
-
* @param {string|ExecuteSqlRequest} query A SQL query or
|
|
1435
|
-
* {@link ExecuteSqlRequest} object.
|
|
1436
|
-
* @param {TimestampBounds} [options] Snapshot timestamp bounds.
|
|
1437
|
-
* @param {RunCallback} [callback] Callback function.
|
|
1438
|
-
* @returns {Promise<RunResponse>}
|
|
1439
|
-
*
|
|
1440
|
-
* @example
|
|
1441
|
-
* ```
|
|
1442
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1443
|
-
* const spanner = new Spanner();
|
|
1444
|
-
*
|
|
1445
|
-
* const instance = spanner.instance('my-instance');
|
|
1446
|
-
* const database = instance.database('my-database');
|
|
1447
|
-
*
|
|
1448
|
-
* const query = 'SELECT * FROM Singers';
|
|
1449
|
-
*
|
|
1450
|
-
* database.run(query, function(err, rows) {
|
|
1451
|
-
* if (err) {
|
|
1452
|
-
* // Error handling omitted.
|
|
1453
|
-
* }
|
|
1454
|
-
*
|
|
1455
|
-
* const firstRow = rows[0];
|
|
1456
|
-
*
|
|
1457
|
-
* // firstRow = [
|
|
1458
|
-
* // {
|
|
1459
|
-
* // name: 'SingerId',
|
|
1460
|
-
* // value: '1'
|
|
1461
|
-
* // },
|
|
1462
|
-
* // {
|
|
1463
|
-
* // name: 'Name',
|
|
1464
|
-
* // value: 'Eddie Wilson'
|
|
1465
|
-
* // }
|
|
1466
|
-
* // ]
|
|
1467
|
-
* });
|
|
1468
|
-
*
|
|
1469
|
-
* //-
|
|
1470
|
-
* // Rows are returned as an array of object arrays. Each object has a `name`
|
|
1471
|
-
* // and `value` property. To get a serialized object, call `toJSON()`.
|
|
1472
|
-
* //-
|
|
1473
|
-
* database.run(query, function(err, rows) {
|
|
1474
|
-
* if (err) {
|
|
1475
|
-
* // Error handling omitted.
|
|
1476
|
-
* }
|
|
1477
|
-
*
|
|
1478
|
-
* const firstRow = rows[0];
|
|
1479
|
-
*
|
|
1480
|
-
* // firstRow.toJSON() = {
|
|
1481
|
-
* // SingerId: '1',
|
|
1482
|
-
* // Name: 'Eddie Wilson'
|
|
1483
|
-
* // }
|
|
1484
|
-
* });
|
|
1485
|
-
*
|
|
1486
|
-
* //-
|
|
1487
|
-
* // Alternatively, set `query.json` to `true`, and this step will be performed
|
|
1488
|
-
* // automatically.
|
|
1489
|
-
* //-
|
|
1490
|
-
* database.run(query, function(err, rows) {
|
|
1491
|
-
* if (err) {
|
|
1492
|
-
* // Error handling omitted.
|
|
1493
|
-
* }
|
|
1494
|
-
*
|
|
1495
|
-
* const firstRow = rows[0];
|
|
1496
|
-
*
|
|
1497
|
-
* // firstRow = {
|
|
1498
|
-
* // SingerId: '1',
|
|
1499
|
-
* // Name: 'Eddie Wilson'
|
|
1500
|
-
* // }
|
|
1501
|
-
* });
|
|
1502
|
-
*
|
|
1503
|
-
* //-
|
|
1504
|
-
* // The SQL query string can contain parameter placeholders. A parameter
|
|
1505
|
-
* // placeholder consists of '@' followed by the parameter name.
|
|
1506
|
-
* //-
|
|
1507
|
-
* const query = {
|
|
1508
|
-
* sql: 'SELECT * FROM Singers WHERE name = @name',
|
|
1509
|
-
* params: {
|
|
1510
|
-
* name: 'Eddie Wilson'
|
|
1511
|
-
* }
|
|
1512
|
-
* };
|
|
1513
|
-
*
|
|
1514
|
-
* database.run(query, function(err, rows) {});
|
|
1515
|
-
*
|
|
1516
|
-
* //-
|
|
1517
|
-
* // If you need to enforce a specific param type, a types map can be provided.
|
|
1518
|
-
* // This is typically useful if your param value can be null.
|
|
1519
|
-
* //-
|
|
1520
|
-
* const query = {
|
|
1521
|
-
* sql: 'SELECT * FROM Singers WHERE name = @name AND id = @id',
|
|
1522
|
-
* params: {
|
|
1523
|
-
* id: spanner.int(8),
|
|
1524
|
-
* name: null
|
|
1525
|
-
* },
|
|
1526
|
-
* types: {
|
|
1527
|
-
* id: 'int64',
|
|
1528
|
-
* name: 'string'
|
|
1529
|
-
* }
|
|
1530
|
-
* };
|
|
1531
|
-
*
|
|
1532
|
-
* database.run(query, function(err, rows) {});
|
|
1533
|
-
*
|
|
1534
|
-
* //-
|
|
1535
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
1536
|
-
* //-
|
|
1537
|
-
* database.run(query).then(function(data) {
|
|
1538
|
-
* const rows = data[0];
|
|
1539
|
-
* });
|
|
1540
|
-
*
|
|
1541
|
-
* ```
|
|
1542
|
-
* @example <caption>include:samples/crud.js</caption>
|
|
1543
|
-
* region_tag:spanner_query_data
|
|
1544
|
-
* Full example:
|
|
1545
|
-
*
|
|
1546
|
-
* @example <caption>include:samples/index-query-data.js</caption>
|
|
1547
|
-
* region_tag:spanner_query_data_with_index
|
|
1548
|
-
* Querying data with an index:
|
|
1549
|
-
*/
|
|
1550
|
-
run(query: string | ExecuteSqlRequest): Promise<RunResponse>;
|
|
1551
|
-
run(query: string | ExecuteSqlRequest, options?: TimestampBounds): Promise<RunResponse>;
|
|
1552
|
-
run(query: string | ExecuteSqlRequest, callback: RunCallback): void;
|
|
1553
|
-
run(query: string | ExecuteSqlRequest, options: TimestampBounds, callback: RunCallback): void;
|
|
1554
|
-
/**
|
|
1555
|
-
* Partitioned DML transactions are used to execute DML statements with a
|
|
1556
|
-
* different execution strategy that provides different, and often better,
|
|
1557
|
-
* scalability properties for large, table-wide operations than DML in a
|
|
1558
|
-
* Transaction transaction. Smaller scoped statements, such as an OLTP workload,
|
|
1559
|
-
* should prefer using Transaction transactions.
|
|
1560
|
-
*
|
|
1561
|
-
* @see {@link Transaction#runUpdate}
|
|
1562
|
-
*
|
|
1563
|
-
* @param {string|ExecuteSqlRequest} query A DML statement or
|
|
1564
|
-
* {@link ExecuteSqlRequest} object.
|
|
1565
|
-
* @param {RunUpdateCallback} [callback] Callback function.
|
|
1566
|
-
* @returns {Promise<RunUpdateResponse>}
|
|
1567
|
-
*/
|
|
1568
|
-
runPartitionedUpdate(query: string | RunPartitionedUpdateOptions): Promise<[number]>;
|
|
1569
|
-
runPartitionedUpdate(query: string | RunPartitionedUpdateOptions, callback?: RunUpdateCallback): void;
|
|
1570
|
-
_runPartitionedUpdate(session: Session, query: string | RunPartitionedUpdateOptions, callback?: RunUpdateCallback): void | Promise<number>;
|
|
1571
|
-
/**
|
|
1572
|
-
* Create a readable object stream to receive resulting rows from a SQL
|
|
1573
|
-
* statement.
|
|
1574
|
-
*
|
|
1575
|
-
* Wrapper around {@link v1.SpannerClient#executeStreamingSql}.
|
|
1576
|
-
*
|
|
1577
|
-
* @see {@link v1.SpannerClient#executeStreamingSql}
|
|
1578
|
-
* @see [Query Syntax](https://cloud.google.com/spanner/docs/query-syntax)
|
|
1579
|
-
* @see [ExecuteSql API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ExecuteSql)
|
|
1580
|
-
*
|
|
1581
|
-
* @fires PartialResultStream#response
|
|
1582
|
-
*
|
|
1583
|
-
* @param {string|ExecuteSqlRequest} query A SQL query or
|
|
1584
|
-
* {@link ExecuteSqlRequest} object.
|
|
1585
|
-
* @param {TimestampBounds} [options] Snapshot timestamp bounds.
|
|
1586
|
-
* @returns {PartialResultStream} A readable stream that emits rows.
|
|
1587
|
-
*
|
|
1588
|
-
* @example
|
|
1589
|
-
* ```
|
|
1590
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1591
|
-
* const spanner = new Spanner();
|
|
1592
|
-
*
|
|
1593
|
-
* const instance = spanner.instance('my-instance');
|
|
1594
|
-
* const database = instance.database('my-database');
|
|
1595
|
-
*
|
|
1596
|
-
* const query = 'SELECT * FROM Singers';
|
|
1597
|
-
*
|
|
1598
|
-
* database.runStream(query)
|
|
1599
|
-
* .on('error', function(err) {})
|
|
1600
|
-
* .on('data', function(row) {
|
|
1601
|
-
* // row = [
|
|
1602
|
-
* // {
|
|
1603
|
-
* // name: 'SingerId',
|
|
1604
|
-
* // value: '1'
|
|
1605
|
-
* // },
|
|
1606
|
-
* // {
|
|
1607
|
-
* // name: 'Name',
|
|
1608
|
-
* // value: 'Eddie Wilson'
|
|
1609
|
-
* // }
|
|
1610
|
-
* // ]
|
|
1611
|
-
* // ]
|
|
1612
|
-
* })
|
|
1613
|
-
* .on('end', function() {
|
|
1614
|
-
* // All results retrieved.
|
|
1615
|
-
* });
|
|
1616
|
-
*
|
|
1617
|
-
* //-
|
|
1618
|
-
* // Rows are returned as an array of objects. Each object has a `name` and
|
|
1619
|
-
* // `value` property. To get a serialized object, call `toJSON()`.
|
|
1620
|
-
* //-
|
|
1621
|
-
* database.runStream(query)
|
|
1622
|
-
* .on('error', function(err) {})
|
|
1623
|
-
* .on('data', function(row) {
|
|
1624
|
-
* // row.toJSON() = {
|
|
1625
|
-
* // SingerId: '1',
|
|
1626
|
-
* // Name: 'Eddie Wilson'
|
|
1627
|
-
* // }
|
|
1628
|
-
* })
|
|
1629
|
-
* .on('end', function() {
|
|
1630
|
-
* // All results retrieved.
|
|
1631
|
-
* });
|
|
1632
|
-
*
|
|
1633
|
-
* //-
|
|
1634
|
-
* // Alternatively, set `query.json` to `true`, and this step will be performed
|
|
1635
|
-
* // automatically.
|
|
1636
|
-
* //-
|
|
1637
|
-
* query.json = true;
|
|
1638
|
-
*
|
|
1639
|
-
* database.runStream(query)
|
|
1640
|
-
* .on('error', function(err) {})
|
|
1641
|
-
* .on('data', function(row) {
|
|
1642
|
-
* // row = {
|
|
1643
|
-
* // SingerId: '1',
|
|
1644
|
-
* // Name: 'Eddie Wilson'
|
|
1645
|
-
* // }
|
|
1646
|
-
* })
|
|
1647
|
-
* .on('end', function() {
|
|
1648
|
-
* // All results retrieved.
|
|
1649
|
-
* });
|
|
1650
|
-
*
|
|
1651
|
-
* //-
|
|
1652
|
-
* // The SQL query string can contain parameter placeholders. A parameter
|
|
1653
|
-
* // placeholder consists of '@' followed by the parameter name.
|
|
1654
|
-
* //-
|
|
1655
|
-
* const query = {
|
|
1656
|
-
* sql: 'SELECT * FROM Singers WHERE name = @name',
|
|
1657
|
-
* params: {
|
|
1658
|
-
* name: 'Eddie Wilson'
|
|
1659
|
-
* }
|
|
1660
|
-
* };
|
|
1661
|
-
*
|
|
1662
|
-
* database.runStream(query)
|
|
1663
|
-
* .on('error', function(err) {})
|
|
1664
|
-
* .on('data', function(row) {})
|
|
1665
|
-
* .on('end', function() {});
|
|
1666
|
-
*
|
|
1667
|
-
* //-
|
|
1668
|
-
* // If you need to enforce a specific param type, a types map can be provided.
|
|
1669
|
-
* // This is typically useful if your param value can be null.
|
|
1670
|
-
* //-
|
|
1671
|
-
* const query = {
|
|
1672
|
-
* sql: 'SELECT * FROM Singers WHERE name = @name',
|
|
1673
|
-
* params: {
|
|
1674
|
-
* name: 'Eddie Wilson'
|
|
1675
|
-
* },
|
|
1676
|
-
* types: {
|
|
1677
|
-
* name: 'string'
|
|
1678
|
-
* }
|
|
1679
|
-
* };
|
|
1680
|
-
*
|
|
1681
|
-
* database.runStream(query)
|
|
1682
|
-
* .on('error', function(err) {})
|
|
1683
|
-
* .on('data', function(row) {})
|
|
1684
|
-
* .on('end', function() {});
|
|
1685
|
-
*
|
|
1686
|
-
* //-
|
|
1687
|
-
* // If you anticipate many results, you can end a stream early to prevent
|
|
1688
|
-
* // unnecessary processing and API requests.
|
|
1689
|
-
* //-
|
|
1690
|
-
* database.runStream(query)
|
|
1691
|
-
* .on('data', function(row) {
|
|
1692
|
-
* this.end();
|
|
1693
|
-
* });
|
|
1694
|
-
* ```
|
|
1695
|
-
*/
|
|
1696
|
-
runStream(query: string | ExecuteSqlRequest, options?: TimestampBounds): PartialResultStream;
|
|
1697
|
-
/**
|
|
1698
|
-
* @typedef {object} RunTransactionOptions
|
|
1699
|
-
* @property {number} [timeout] The maximum amount of time (in ms) that a
|
|
1700
|
-
* {@link Transaction} should be ran for.
|
|
1701
|
-
*/
|
|
1702
|
-
/**
|
|
1703
|
-
* @callback RunTransactionCallback
|
|
1704
|
-
* @param {?Error} err An error returned while making this request.
|
|
1705
|
-
* @param {Transaction} transaction The transaction object. The transaction has
|
|
1706
|
-
* already been created, and is ready to be queried and committed against.
|
|
1707
|
-
*/
|
|
1708
|
-
/**
|
|
1709
|
-
* A transaction in Cloud Spanner is a set of reads and writes that execute
|
|
1710
|
-
* atomically at a single logical point in time across columns, rows, and tables
|
|
1711
|
-
* in a database.
|
|
1712
|
-
*
|
|
1713
|
-
* Note that Cloud Spanner does not support nested transactions. If a new
|
|
1714
|
-
* transaction is started inside of the run function, it will be an independent
|
|
1715
|
-
* transaction.
|
|
1716
|
-
*
|
|
1717
|
-
* The callback you provide to this function will become the "run function". It
|
|
1718
|
-
* will be executed with either an error or a {@link Transaction}
|
|
1719
|
-
* object. The Transaction object will let you run queries and queue mutations
|
|
1720
|
-
* until you are ready to {@link Transaction#commit}.
|
|
1721
|
-
*
|
|
1722
|
-
* In the event that an aborted error occurs, we will re-run the `runFn` in its
|
|
1723
|
-
* entirety. If you prefer to handle aborted errors for yourself please refer to
|
|
1724
|
-
* {@link Database#getTransaction}.
|
|
1725
|
-
*
|
|
1726
|
-
* **NOTE:** In the event that you encounter an error while reading/writing,
|
|
1727
|
-
* if you decide to forgo calling {@link Transaction#commit} or
|
|
1728
|
-
* {@link Transaction#rollback}, then you need to call
|
|
1729
|
-
* {@link Transaction#end} to release the underlying {@link Session} object.
|
|
1730
|
-
* **Failure to do could result in a Session leak.**
|
|
1731
|
-
*
|
|
1732
|
-
* For a more complete listing of functionality available to a Transaction, see
|
|
1733
|
-
* the {@link Transaction} API documentation. For a general overview of
|
|
1734
|
-
* transactions within Cloud Spanner, see
|
|
1735
|
-
* [Transactions](https://cloud.google.com/spanner/docs/transactions) from the
|
|
1736
|
-
* official Cloud Spanner documentation.
|
|
1737
|
-
*
|
|
1738
|
-
* If you would like to run a transaction and receive a promise or use
|
|
1739
|
-
* async/await, use {@link Database#runTransactionAsync}.
|
|
1740
|
-
*
|
|
1741
|
-
* @see [Transactions](https://cloud.google.com/spanner/docs/transactions)
|
|
1742
|
-
*
|
|
1743
|
-
* @param {RunTransactionOptions} [options] Transaction runner options.
|
|
1744
|
-
* @param {RunTransactionCallback} callback A function to execute in the context
|
|
1745
|
-
* of a transaction.
|
|
1746
|
-
*
|
|
1747
|
-
* @example
|
|
1748
|
-
* ```
|
|
1749
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1750
|
-
* const spanner = new Spanner();
|
|
1751
|
-
*
|
|
1752
|
-
* const instance = spanner.instance('my-instance');
|
|
1753
|
-
* const database = instance.database('my-database');
|
|
1754
|
-
*
|
|
1755
|
-
* database.runTransaction(function(err, transaction) {
|
|
1756
|
-
* if (err) {
|
|
1757
|
-
* // Error handling omitted.
|
|
1758
|
-
* }
|
|
1759
|
-
*
|
|
1760
|
-
* // Run a transactional query.
|
|
1761
|
-
* transaction.run('SELECT * FROM Singers', function(err, rows) {
|
|
1762
|
-
* if (err) {
|
|
1763
|
-
* // Error handling omitted.
|
|
1764
|
-
* }
|
|
1765
|
-
*
|
|
1766
|
-
* // Queue a mutation (note that there is no callback passed to `insert`).
|
|
1767
|
-
* transaction.insert('Singers', {
|
|
1768
|
-
* SingerId: 'Id3b',
|
|
1769
|
-
* Name: 'Joe West'
|
|
1770
|
-
* });
|
|
1771
|
-
*
|
|
1772
|
-
* // Commit the transaction.
|
|
1773
|
-
* transaction.commit(function(err) {
|
|
1774
|
-
* if (!err) {
|
|
1775
|
-
* // Transaction committed successfully.
|
|
1776
|
-
* }
|
|
1777
|
-
* });
|
|
1778
|
-
* });
|
|
1779
|
-
* });
|
|
1780
|
-
*
|
|
1781
|
-
* ```
|
|
1782
|
-
* @example <caption>include:samples/transaction.js</caption>
|
|
1783
|
-
* region_tag:spanner_read_write_transaction
|
|
1784
|
-
* Read-write transaction:
|
|
1785
|
-
*/
|
|
1786
|
-
runTransaction(runFn: RunTransactionCallback): void;
|
|
1787
|
-
runTransaction(options: RunTransactionOptions, runFn: RunTransactionCallback): void;
|
|
1788
|
-
runTransactionAsync<T = {}>(runFn: AsyncRunTransactionCallback<T>): Promise<T>;
|
|
1789
|
-
runTransactionAsync<T = {}>(options: RunTransactionOptions, runFn: AsyncRunTransactionCallback<T>): Promise<T>;
|
|
1790
|
-
/**
|
|
1791
|
-
* Write a batch of mutations to Spanner.
|
|
1792
|
-
*
|
|
1793
|
-
* All mutations in a group are committed atomically. However, mutations across
|
|
1794
|
-
* groups can be committed non-atomically in an unspecified order and thus, they
|
|
1795
|
-
* must be independent of each other. Partial failure is possible, i.e., some groups
|
|
1796
|
-
* may have been committed successfully, while some may have failed. The results of
|
|
1797
|
-
* individual batches are streamed into the response as the batches are applied.
|
|
1798
|
-
*
|
|
1799
|
-
* batchWriteAtLeastOnce requests are not replay protected, meaning that each mutation group may
|
|
1800
|
-
* be applied more than once. Replays of non-idempotent mutations may have undesirable
|
|
1801
|
-
* effects. For example, replays of an insert mutation may produce an already exists
|
|
1802
|
-
* error or if you use generated or commit timestamp-based keys, it may result in additional
|
|
1803
|
-
* rows being added to the mutation's table. We recommend structuring your mutation groups to
|
|
1804
|
-
* be idempotent to avoid this issue.
|
|
1805
|
-
*
|
|
1806
|
-
* @method Spanner#batchWriteAtLeastOnce
|
|
1807
|
-
*
|
|
1808
|
-
* @param {MutationGroup[]} [mutationGroups] The group of mutations to be applied.
|
|
1809
|
-
* @param {BatchWriteOptions} [options] Options object for batch write request.
|
|
1810
|
-
*
|
|
1811
|
-
* @returns {ReadableStream} An object stream which emits
|
|
1812
|
-
* {@link protos.google.spanner.v1.BatchWriteResponse|BatchWriteResponse}
|
|
1813
|
-
* on 'data' event.
|
|
1814
|
-
*
|
|
1815
|
-
* @example
|
|
1816
|
-
* ```
|
|
1817
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1818
|
-
* const spanner = new Spanner();
|
|
1819
|
-
*
|
|
1820
|
-
* const instance = spanner.instance('my-instance');
|
|
1821
|
-
* const database = instance.database('my-database');
|
|
1822
|
-
* const mutationGroup = new MutationGroup();
|
|
1823
|
-
* mutationGroup.insert('Singers', {
|
|
1824
|
-
* SingerId: '1',
|
|
1825
|
-
* FirstName: 'Marc',
|
|
1826
|
-
* LastName: 'Richards',
|
|
1827
|
-
* });
|
|
1828
|
-
*
|
|
1829
|
-
* database.batchWriteAtLeastOnce([mutationGroup])
|
|
1830
|
-
* .on('error', console.error)
|
|
1831
|
-
* .on('data', response => {
|
|
1832
|
-
* console.log('response: ', response);
|
|
1833
|
-
* })
|
|
1834
|
-
* .on('end', () => {
|
|
1835
|
-
* console.log('Request completed successfully');
|
|
1836
|
-
* });
|
|
1837
|
-
*
|
|
1838
|
-
* //-
|
|
1839
|
-
* // If you anticipate many results, you can end a stream early to prevent
|
|
1840
|
-
* // unnecessary processing and API requests.
|
|
1841
|
-
* //-
|
|
1842
|
-
* database.batchWriteAtLeastOnce()
|
|
1843
|
-
* .on('data', response => {
|
|
1844
|
-
* this.end();
|
|
1845
|
-
* });
|
|
1846
|
-
* ```
|
|
1847
|
-
*/
|
|
1848
|
-
batchWriteAtLeastOnce(mutationGroups: MutationGroup[], options?: BatchWriteOptions): NodeJS.ReadableStream;
|
|
1849
|
-
/**
|
|
1850
|
-
* Write mutations using a single RPC invocation without replay protection.
|
|
1851
|
-
*
|
|
1852
|
-
* writeAtLeastOnce writes mutations to Spanner using a single Commit RPC.
|
|
1853
|
-
* These requests are not replay protected, meaning that it may apply mutations more
|
|
1854
|
-
* than once, if the mutations are not idempotent, this may lead to a failure being
|
|
1855
|
-
* reported when the mutation was applied once. Replays non-idempotent mutations may
|
|
1856
|
-
* have undesirable effects. For example, replays of an insert mutation may produce an
|
|
1857
|
-
* already exists error. For this reason, most users of the library will prefer to use
|
|
1858
|
-
* {@link runTransaction} instead.
|
|
1859
|
-
*
|
|
1860
|
-
* However, {@link writeAtLeastOnce()} requires only a single RPC, whereas {@link runTransaction()}
|
|
1861
|
-
* requires two RPCs (one of which may be performed in advance), and so this method may be
|
|
1862
|
-
* appropriate for latency sensitive and/or high throughput blind writing.
|
|
1863
|
-
*
|
|
1864
|
-
* We recommend structuring your mutation set to be idempotent to avoid this issue.
|
|
1865
|
-
*
|
|
1866
|
-
* @param {MutationSet} [mutations] Set of Mutations to be applied.
|
|
1867
|
-
* @param {CallOptions} [options] Options object for blind write request.
|
|
1868
|
-
* @param {CommitCallback} [callback] Callback function for blind write request.
|
|
1869
|
-
*
|
|
1870
|
-
* @returns {Promise}
|
|
1871
|
-
*
|
|
1872
|
-
* @example
|
|
1873
|
-
* ```
|
|
1874
|
-
* const {Spanner, MutationSet} = require('@google-cloud/spanner');
|
|
1875
|
-
* const spanner = new Spanner();
|
|
1876
|
-
*
|
|
1877
|
-
* const instance = spanner.instance('my-instance');
|
|
1878
|
-
* const database = instance.database('my-database');
|
|
1879
|
-
* const mutations = new MutationSet();
|
|
1880
|
-
* mutations.upsert('Singers', {
|
|
1881
|
-
* SingerId: 1,
|
|
1882
|
-
* FirstName: 'Scarlet',
|
|
1883
|
-
* LastName: 'Terry',
|
|
1884
|
-
* });
|
|
1885
|
-
* mutations.upsert('Singers', {
|
|
1886
|
-
* SingerId: 2,
|
|
1887
|
-
* FirstName: 'Marc',
|
|
1888
|
-
* LastName: 'Richards',
|
|
1889
|
-
* });
|
|
1890
|
-
*
|
|
1891
|
-
* try {
|
|
1892
|
-
* const [response] = await database.writeAtLeastOnce(mutations, {});
|
|
1893
|
-
* console.log(response.commitTimestamp);
|
|
1894
|
-
* } catch(err) {
|
|
1895
|
-
* console.log("Error: ", err);
|
|
1896
|
-
* }
|
|
1897
|
-
* ```
|
|
1898
|
-
*/
|
|
1899
|
-
writeAtLeastOnce(mutations: MutationSet): Promise<CommitResponse>;
|
|
1900
|
-
writeAtLeastOnce(mutations: MutationSet, options: CallOptions): Promise<CommitResponse>;
|
|
1901
|
-
writeAtLeastOnce(mutations: MutationSet, callback: CommitCallback): void;
|
|
1902
|
-
writeAtLeastOnce(mutations: MutationSet, options: CallOptions, callback: CommitCallback): void;
|
|
1903
|
-
/**
|
|
1904
|
-
* Create a Session object.
|
|
1905
|
-
*
|
|
1906
|
-
* It is unlikely you will need to interact with sessions directly. By default,
|
|
1907
|
-
* sessions are created and utilized for maximum performance automatically.
|
|
1908
|
-
*
|
|
1909
|
-
* @param {string} [name] The name of the session. If not provided, it is
|
|
1910
|
-
* assumed you are going to create it.
|
|
1911
|
-
* @returns {Session} A Session object.
|
|
1912
|
-
*
|
|
1913
|
-
* @example
|
|
1914
|
-
* ```
|
|
1915
|
-
* var session = database.session('session-name');
|
|
1916
|
-
* ```
|
|
1917
|
-
*/
|
|
1918
|
-
session(name?: string): Session;
|
|
1919
|
-
/**
|
|
1920
|
-
* Get a reference to a Table object.
|
|
1921
|
-
*
|
|
1922
|
-
* @throws {GoogleError} If a name is not provided.
|
|
1923
|
-
*
|
|
1924
|
-
* @param {string} name The name of the table.
|
|
1925
|
-
* @return {Table} A Table object.
|
|
1926
|
-
*
|
|
1927
|
-
* @example
|
|
1928
|
-
* ```
|
|
1929
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1930
|
-
* const spanner = new Spanner();
|
|
1931
|
-
*
|
|
1932
|
-
* const instance = spanner.instance('my-instance');
|
|
1933
|
-
* const database = instance.database('my-database');
|
|
1934
|
-
*
|
|
1935
|
-
* const table = database.table('Singers');
|
|
1936
|
-
* ```
|
|
1937
|
-
*/
|
|
1938
|
-
/**
|
|
1939
|
-
* @callback SetIamPolicyCallback
|
|
1940
|
-
* @param {?Error} err Request error, if any.
|
|
1941
|
-
* @param {google.iam.v1.Policy| undefined} policy Returns policy for the give database
|
|
1942
|
-
*/
|
|
1943
|
-
/**
|
|
1944
|
-
* Sets the policy for the database.
|
|
1945
|
-
*
|
|
1946
|
-
* A Policy is a collection of bindings. A binding binds one or more members, or principals,
|
|
1947
|
-
* to a single role. Principals can be user accounts, service accounts, Google groups, and
|
|
1948
|
-
* domains (such as G Suite). A role is a named list of permissions; each role can be an IAM
|
|
1949
|
-
* predefined role or a user-created custom role.
|
|
1950
|
-
*
|
|
1951
|
-
* @see {@link #setIamPolicy}
|
|
1952
|
-
*
|
|
1953
|
-
* @method Database#setIamPolicy
|
|
1954
|
-
* @param {object} [policy] requestedPolicyVersion and gax options(configuration options)
|
|
1955
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
|
|
1956
|
-
* for more details on gax options.
|
|
1957
|
-
* @param {object} [options] Requested configuration options,
|
|
1958
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
|
|
1959
|
-
* for more details on Call Options.
|
|
1960
|
-
* @param {SetIamPolicyCallback} [callback] Callback function.
|
|
1961
|
-
* @returns {Promise<Policy | undefined>}
|
|
1962
|
-
* When resolved, contains the current policy of the database.
|
|
1963
|
-
*
|
|
1964
|
-
* @example
|
|
1965
|
-
* ```
|
|
1966
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
1967
|
-
* const spanner = new Spanner();
|
|
1968
|
-
* const instance = spanner.instance('my-instance');
|
|
1969
|
-
* const database = instance.database('my-database');
|
|
1970
|
-
* const binding = {
|
|
1971
|
-
* role: 'roles/spanner.fineGrainedAccessUser',
|
|
1972
|
-
* members: ['user:asthamohta@google.com'],
|
|
1973
|
-
* condition: {
|
|
1974
|
-
* title: 'new condition',
|
|
1975
|
-
* expression: 'resource.name.endsWith("/databaseRoles/parent")',
|
|
1976
|
-
* },
|
|
1977
|
-
* };
|
|
1978
|
-
* const policy = {
|
|
1979
|
-
* bindings: [newBinding],
|
|
1980
|
-
* version: 3,
|
|
1981
|
-
*};
|
|
1982
|
-
* const policy = await database.setIamPolicy({policy: policy});
|
|
1983
|
-
* ```
|
|
1984
|
-
*/
|
|
1985
|
-
setIamPolicy(policy: SetIamPolicyRequest): Promise<SetIamPolicyResponse>;
|
|
1986
|
-
setIamPolicy(policy: SetIamPolicyRequest, options?: CallOptions): Promise<SetIamPolicyResponse>;
|
|
1987
|
-
setIamPolicy(policy: SetIamPolicyRequest, callback: SetIamPolicyCallback): void;
|
|
1988
|
-
setIamPolicy(policy: SetIamPolicyRequest, options: CallOptions, callback: SetIamPolicyCallback): void;
|
|
1989
|
-
table(name: string): Table;
|
|
1990
|
-
/**
|
|
1991
|
-
* Update the schema of the database by creating/altering/dropping tables,
|
|
1992
|
-
* columns, indexes, etc.
|
|
1993
|
-
*
|
|
1994
|
-
* This method immediately responds with an Operation object. Register event
|
|
1995
|
-
* handlers for the "error" and "complete" events to see how the operation
|
|
1996
|
-
* finishes. Follow along with the examples below.
|
|
1997
|
-
*
|
|
1998
|
-
* Wrapper around {@link v1.DatabaseAdminClient#updateDatabaseDdl}.
|
|
1999
|
-
*
|
|
2000
|
-
* @see {@link v1.DatabaseAdminClient#updateDatabaseDdl}
|
|
2001
|
-
* @see [Data Definition Language (DDL)](https://cloud.google.com/spanner/docs/data-definition-language)
|
|
2002
|
-
* @see [Schema and Data Model](https://cloud.google.com/spanner/docs/schema-and-data-model)
|
|
2003
|
-
* @see [UpdateDatabaseDdl API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.UpdateDatabaseDdlRequest)
|
|
2004
|
-
*
|
|
2005
|
-
* @param {string|string[]|object} statements An array of database DDL
|
|
2006
|
-
* statements, or an
|
|
2007
|
-
* [`UpdateDatabaseDdlRequest` object](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.UpdateDatabaseDdlRequest).
|
|
2008
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
2009
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
2010
|
-
* for more details.
|
|
2011
|
-
* @param {LongRunningOperationCallback} [callback] Callback function.
|
|
2012
|
-
* @returns {Promise<LongRunningOperationResponse>}
|
|
2013
|
-
*
|
|
2014
|
-
* @example
|
|
2015
|
-
* ```
|
|
2016
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
2017
|
-
* const spanner = new Spanner();
|
|
2018
|
-
*
|
|
2019
|
-
* const instance = spanner.instance('my-instance');
|
|
2020
|
-
* const database = instance.database('my-database');
|
|
2021
|
-
*
|
|
2022
|
-
* const statements = [
|
|
2023
|
-
* 'CREATE TABLE Singers (' +
|
|
2024
|
-
* ' SingerId INT64 NOT NULL,' +
|
|
2025
|
-
* ' FirstName STRING(1024),' +
|
|
2026
|
-
* ' LastName STRING(1024),' +
|
|
2027
|
-
* ' SingerInfo BYTES(MAX),' +
|
|
2028
|
-
* ') PRIMARY KEY(SingerId)'
|
|
2029
|
-
* ];
|
|
2030
|
-
*
|
|
2031
|
-
* database.updateSchema(statements, function(err, operation, apiResponse) {
|
|
2032
|
-
* if (err) {
|
|
2033
|
-
* // Error handling omitted.
|
|
2034
|
-
* }
|
|
2035
|
-
*
|
|
2036
|
-
* operation
|
|
2037
|
-
* .on('error', function(err) {})
|
|
2038
|
-
* .on('complete', function() {
|
|
2039
|
-
* // Database schema updated successfully.
|
|
2040
|
-
* });
|
|
2041
|
-
* });
|
|
2042
|
-
*
|
|
2043
|
-
* //-
|
|
2044
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
2045
|
-
* //-
|
|
2046
|
-
* database.updateSchema(statements)
|
|
2047
|
-
* .then(function(data) {
|
|
2048
|
-
* const operation = data[0];
|
|
2049
|
-
* return operation.promise();
|
|
2050
|
-
* })
|
|
2051
|
-
* .then(function() {
|
|
2052
|
-
* // Database schema updated successfully.
|
|
2053
|
-
* });
|
|
2054
|
-
*
|
|
2055
|
-
* ```
|
|
2056
|
-
* @example <caption>include:samples/schema.js</caption>
|
|
2057
|
-
* region_tag:spanner_add_column
|
|
2058
|
-
* Adding a column:
|
|
2059
|
-
*
|
|
2060
|
-
* @example <caption>include:samples/index-create.js</caption>
|
|
2061
|
-
* region_tag:spanner_create_index
|
|
2062
|
-
* Creating an index:
|
|
2063
|
-
*
|
|
2064
|
-
* @example <caption>include:samples/index-create-stroing.js</caption>
|
|
2065
|
-
* region_tag:spanner_create_storing_index
|
|
2066
|
-
* Creating a storing index:
|
|
2067
|
-
*/
|
|
2068
|
-
updateSchema(statements: Schema, gaxOptions?: CallOptions): Promise<UpdateSchemaResponse>;
|
|
2069
|
-
updateSchema(statements: Schema, callback: UpdateSchemaCallback): void;
|
|
2070
|
-
updateSchema(statements: Schema, gaxOptions: CallOptions, callback: UpdateSchemaCallback): void;
|
|
2071
|
-
/**
|
|
2072
|
-
* Format the database name to include the instance name.
|
|
2073
|
-
*
|
|
2074
|
-
* @private
|
|
2075
|
-
*
|
|
2076
|
-
* @param {string} instanceName The formatted instance name.
|
|
2077
|
-
* @param {string} name The table name.
|
|
2078
|
-
* @returns {string}
|
|
2079
|
-
*
|
|
2080
|
-
* @example
|
|
2081
|
-
* ```
|
|
2082
|
-
* Database.formatName_(
|
|
2083
|
-
* 'projects/grape-spaceship-123/instances/my-instance',
|
|
2084
|
-
* 'my-database'
|
|
2085
|
-
* );
|
|
2086
|
-
* // 'projects/grape-spaceship-123/instances/my-instance/databases/my-database'
|
|
2087
|
-
* ```
|
|
2088
|
-
*/
|
|
2089
|
-
static formatName_(instanceName: string, name: string): string;
|
|
2090
|
-
/**
|
|
2091
|
-
* Gets the Spanner object
|
|
2092
|
-
*
|
|
2093
|
-
* @private
|
|
2094
|
-
*
|
|
2095
|
-
* @returns {Spanner}
|
|
2096
|
-
*/
|
|
2097
|
-
private _getSpanner;
|
|
2098
|
-
}
|
|
2099
|
-
/**
|
|
2100
|
-
* Reference to the {@link Database} class.
|
|
2101
|
-
* @name module:@google-cloud/spanner.Database
|
|
2102
|
-
* @see Database
|
|
2103
|
-
*/
|
|
2104
|
-
export { Database };
|