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