@google-cloud/spanner 7.18.0 → 7.18.1

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 (82) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -0
  3. package/build/protos/google/spanner/admin/database/v1/backup.proto +757 -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 +1209 -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 +575 -0
  17. package/build/protos/google/spanner/v1/type.proto +214 -0
  18. package/build/protos/protos.d.ts +39317 -0
  19. package/build/protos/protos.js +100360 -0
  20. package/build/protos/protos.json +10271 -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 +1655 -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 +136 -0
  47. package/build/src/multiplexed-session.js +197 -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/session-factory.d.ts +100 -0
  51. package/build/src/session-factory.js +93 -0
  52. package/build/src/session-pool.d.ts +471 -0
  53. package/build/src/session-pool.js +754 -0
  54. package/build/src/session.d.ts +258 -0
  55. package/build/src/session.js +348 -0
  56. package/build/src/spanner_grpc_config.json +92 -0
  57. package/build/src/table.d.ts +831 -0
  58. package/build/src/table.js +277 -0
  59. package/build/src/transaction-runner.d.ts +185 -0
  60. package/build/src/transaction-runner.js +282 -0
  61. package/build/src/transaction.d.ts +1691 -0
  62. package/build/src/transaction.js +2004 -0
  63. package/build/src/v1/database_admin_client.d.ts +2301 -0
  64. package/build/src/v1/database_admin_client.js +2286 -0
  65. package/build/src/v1/database_admin_client_config.json +160 -0
  66. package/build/src/v1/database_admin_proto_list.json +6 -0
  67. package/build/src/v1/gapic_metadata.json +27 -0
  68. package/build/src/v1/index.d.ts +4 -0
  69. package/build/src/v1/index.js +29 -0
  70. package/build/src/v1/instance_admin_client.d.ts +1985 -0
  71. package/build/src/v1/instance_admin_client.js +1768 -0
  72. package/build/src/v1/instance_admin_client_config.json +129 -0
  73. package/build/src/v1/instance_admin_proto_list.json +4 -0
  74. package/build/src/v1/spanner_client.d.ts +1250 -0
  75. package/build/src/v1/spanner_client.js +1086 -0
  76. package/build/src/v1/spanner_client_config.json +119 -0
  77. package/build/src/v1/spanner_executor_proxy_client.d.ts +418 -0
  78. package/build/src/v1/spanner_executor_proxy_client.js +706 -0
  79. package/build/src/v1/spanner_executor_proxy_client_config.json +30 -0
  80. package/build/src/v1/spanner_executor_proxy_proto_list.json +14 -0
  81. package/build/src/v1/spanner_proto_list.json +10 -0
  82. package/package.json +1 -1
@@ -0,0 +1,1691 @@
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 { PreciseDate } from '@google-cloud/precise-date';
17
+ import Long = require('long');
18
+ import { EventEmitter } from 'events';
19
+ import { grpc, CallOptions } from 'google-gax';
20
+ import { common as p } from 'protobufjs';
21
+ import { Readable } from 'stream';
22
+ import { Json, JSONOptions, Type, Value } from './codec';
23
+ import { PartialResultStream, ResumeToken, Row } from './partial-result-stream';
24
+ import { Session } from './session';
25
+ import { Key } from './table';
26
+ import { google as spannerClient } from '../protos/protos';
27
+ import { NormalCallback } from './common';
28
+ import { google } from '../protos/protos';
29
+ import IQueryOptions = google.spanner.v1.ExecuteSqlRequest.IQueryOptions;
30
+ import IRequestOptions = google.spanner.v1.IRequestOptions;
31
+ import { Spanner } from '.';
32
+ import { ObservabilityOptions } from './instrument';
33
+ export type Rows = Array<Row | Json>;
34
+ export interface TimestampBounds {
35
+ strong?: boolean;
36
+ minReadTimestamp?: PreciseDate | spannerClient.protobuf.ITimestamp;
37
+ maxStaleness?: number | spannerClient.protobuf.IDuration;
38
+ readTimestamp?: PreciseDate | spannerClient.protobuf.ITimestamp;
39
+ exactStaleness?: number | spannerClient.protobuf.IDuration;
40
+ returnReadTimestamp?: boolean;
41
+ }
42
+ export interface BatchWriteOptions {
43
+ requestOptions?: Pick<IRequestOptions, 'priority' | 'transactionTag'>;
44
+ gaxOptions?: CallOptions;
45
+ excludeTxnFromChangeStreams?: boolean;
46
+ }
47
+ export interface RequestOptions {
48
+ json?: boolean;
49
+ jsonOptions?: JSONOptions;
50
+ gaxOptions?: CallOptions;
51
+ maxResumeRetries?: number;
52
+ /**
53
+ * An object where column names as keys and custom objects as corresponding
54
+ * values for deserialization. This is only needed for proto columns
55
+ * where deserialization logic is on user-specific code. When provided,
56
+ * the custom object enables deserialization of backend-received column data.
57
+ * If not provided, data remains serialized as buffer for Proto Messages and
58
+ * integer for Proto Enums.
59
+ *
60
+ * @example
61
+ * To obtain Proto Messages and Proto Enums as JSON objects, you must supply
62
+ * additional metadata. This metadata should include the protobufjs-cli
63
+ * generated proto message function and enum object. It encompasses the essential
64
+ * logic for proper data deserialization.
65
+ *
66
+ * Eg: To read data from Proto Columns in json format using DQL, you should pass
67
+ * columnsMetadata where key is the name of the column and value is the protobufjs-cli
68
+ * generated proto message function and enum object.
69
+ *
70
+ * const query = {
71
+ * sql: `SELECT SingerId,
72
+ * FirstName,
73
+ * LastName,
74
+ * SingerInfo,
75
+ * SingerGenre,
76
+ * SingerInfoArray,
77
+ * SingerGenreArray
78
+ * FROM Singers
79
+ * WHERE SingerId = 6`,
80
+ * columnsMetadata: {
81
+ * SingerInfo: music.SingerInfo,
82
+ * SingerInfoArray: music.SingerInfo,
83
+ * SingerGenre: music.Genre,
84
+ * SingerGenreArray: music.Genre,
85
+ * },
86
+ * };
87
+ */
88
+ columnsMetadata?: object;
89
+ }
90
+ export interface CommitOptions {
91
+ requestOptions?: Pick<IRequestOptions, 'priority'>;
92
+ returnCommitStats?: boolean;
93
+ maxCommitDelay?: spannerClient.protobuf.IDuration;
94
+ gaxOptions?: CallOptions;
95
+ }
96
+ export interface Statement {
97
+ sql: string;
98
+ params?: {
99
+ [param: string]: Value;
100
+ };
101
+ types?: Type | {
102
+ [param: string]: Value;
103
+ };
104
+ }
105
+ export interface ExecuteSqlRequest extends Statement, RequestOptions {
106
+ resumeToken?: ResumeToken;
107
+ queryMode?: spannerClient.spanner.v1.ExecuteSqlRequest.QueryMode;
108
+ partitionToken?: Uint8Array | string;
109
+ seqno?: number;
110
+ queryOptions?: IQueryOptions;
111
+ requestOptions?: Omit<IRequestOptions, 'transactionTag'>;
112
+ dataBoostEnabled?: boolean | null;
113
+ directedReadOptions?: google.spanner.v1.IDirectedReadOptions;
114
+ }
115
+ export interface KeyRange {
116
+ startClosed?: Value[];
117
+ startOpen?: Value[];
118
+ endClosed?: Value[];
119
+ endOpen?: Value[];
120
+ }
121
+ export interface ReadRequest extends RequestOptions {
122
+ table?: string;
123
+ index?: string;
124
+ columns?: string[] | null;
125
+ keys?: string[] | string[][];
126
+ ranges?: KeyRange[];
127
+ keySet?: spannerClient.spanner.v1.IKeySet | null;
128
+ limit?: number | Long | string | null;
129
+ resumeToken?: Uint8Array | null;
130
+ partitionToken?: Uint8Array | null;
131
+ requestOptions?: Omit<IRequestOptions, 'transactionTag'>;
132
+ dataBoostEnabled?: boolean | null;
133
+ directedReadOptions?: google.spanner.v1.IDirectedReadOptions;
134
+ }
135
+ export interface BatchUpdateError extends grpc.ServiceError {
136
+ rowCounts: number[];
137
+ }
138
+ export type CommitRequest = spannerClient.spanner.v1.ICommitRequest;
139
+ export type BatchUpdateResponse = [
140
+ number[],
141
+ spannerClient.spanner.v1.ExecuteBatchDmlResponse
142
+ ];
143
+ export type BeginResponse = [spannerClient.spanner.v1.ITransaction];
144
+ export type BeginTransactionCallback = NormalCallback<spannerClient.spanner.v1.ITransaction>;
145
+ export type CommitResponse = [spannerClient.spanner.v1.ICommitResponse];
146
+ export type ReadResponse = [Rows];
147
+ export type RunResponse = [
148
+ Rows,
149
+ spannerClient.spanner.v1.ResultSetStats,
150
+ spannerClient.spanner.v1.ResultSetMetadata
151
+ ];
152
+ export type RunUpdateResponse = [number];
153
+ export interface BatchUpdateOptions {
154
+ requestOptions?: Omit<IRequestOptions, 'transactionTag'>;
155
+ gaxOptions?: CallOptions;
156
+ }
157
+ export interface BatchUpdateCallback {
158
+ (err: null | BatchUpdateError, rowCounts: number[], response?: spannerClient.spanner.v1.ExecuteBatchDmlResponse): void;
159
+ }
160
+ export interface BatchUpdateOptions {
161
+ requestOptions?: Omit<IRequestOptions, 'transactionTag'>;
162
+ gaxOptions?: CallOptions;
163
+ }
164
+ export type ReadCallback = NormalCallback<Rows>;
165
+ export interface RunCallback {
166
+ (err: null | grpc.ServiceError, rows: Rows, stats: spannerClient.spanner.v1.ResultSetStats, metadata?: spannerClient.spanner.v1.ResultSetMetadata): void;
167
+ }
168
+ export interface RunUpdateCallback {
169
+ (err: null | grpc.ServiceError, rowCount: number): void;
170
+ }
171
+ export type CommitCallback = NormalCallback<spannerClient.spanner.v1.ICommitResponse>;
172
+ /**
173
+ * @typedef {object} TimestampBounds
174
+ * @property {boolean} [strong=true] Read at a timestamp where all previously
175
+ * committed transactions are visible.
176
+ * @property {external:PreciseDate|google.protobuf.Timestamp} [minReadTimestamp]
177
+ * Executes all reads at a `timestamp >= minReadTimestamp`.
178
+ * @property {number|google.protobuf.Timestamp} [maxStaleness] Read data at a
179
+ * `timestamp >= NOW - maxStaleness` (milliseconds).
180
+ * @property {external:PreciseDate|google.protobuf.Timestamp} [readTimestamp]
181
+ * Executes all reads at the given timestamp.
182
+ * @property {number|google.protobuf.Timestamp} [exactStaleness] Executes all
183
+ * reads at a timestamp that is `exactStaleness` (milliseconds) old.
184
+ * @property {boolean} [returnReadTimestamp=true] When true,
185
+ * {@link Snapshot#readTimestamp} will be populated after
186
+ * {@link Snapshot#begin} is called.
187
+ */
188
+ /**
189
+ * This transaction type provides guaranteed consistency across several reads,
190
+ * but does not allow writes. Snapshot read-only transactions can be configured
191
+ * to read at timestamps in the past.
192
+ *
193
+ * When finished with the Snapshot, call {@link Snapshot#end} to
194
+ * release the underlying {@link Session}. Failure to do so can result in a
195
+ * Session leak.
196
+ *
197
+ * **This object is created and returned from {@link Database#getSnapshot}.**
198
+ *
199
+ * @class
200
+ * @hideconstructor
201
+ *
202
+ * @see [Timestamp Bounds API Documentation](https://cloud.google.com/spanner/docs/timestamp-bounds)
203
+ *
204
+ * @example
205
+ * ```
206
+ * const {Spanner} = require('@google-cloud/spanner');
207
+ * const spanner = new Spanner();
208
+ *
209
+ * const instance = spanner.instance('my-instance');
210
+ * const database = instance.database('my-database');
211
+ *
212
+ * const timestampBounds = {
213
+ * strong: true
214
+ * };
215
+ *
216
+ * database.getSnapshot(timestampBounds, (err, transaction) => {
217
+ * if (err) {
218
+ * // Error handling omitted.
219
+ * }
220
+ *
221
+ * // It should be called when the snapshot finishes.
222
+ * transaction.end();
223
+ * });
224
+ * ```
225
+ */
226
+ export declare class Snapshot extends EventEmitter {
227
+ protected _options: spannerClient.spanner.v1.ITransactionOptions;
228
+ protected _seqno: number;
229
+ protected _waitingRequests: Array<() => void>;
230
+ protected _inlineBeginStarted: any;
231
+ protected _useInRunner: boolean;
232
+ id?: Uint8Array | string;
233
+ ended: boolean;
234
+ metadata?: spannerClient.spanner.v1.ITransaction;
235
+ readTimestamp?: PreciseDate;
236
+ readTimestampProto?: spannerClient.protobuf.ITimestamp;
237
+ request: (config: {}, callback: Function) => void;
238
+ requestStream: (config: {}) => Readable;
239
+ session: Session;
240
+ queryOptions?: IQueryOptions;
241
+ commonHeaders_: {
242
+ [k: string]: string;
243
+ };
244
+ requestOptions?: Pick<IRequestOptions, 'transactionTag'>;
245
+ _observabilityOptions?: ObservabilityOptions;
246
+ protected _dbName?: string;
247
+ /**
248
+ * The transaction ID.
249
+ *
250
+ * @name Snapshot#id
251
+ * @type {?(string|Buffer)}
252
+ */
253
+ /**
254
+ * Whether or not the transaction has ended. If true, make no further
255
+ * requests, and discard the transaction.
256
+ *
257
+ * @name Snapshot#ended
258
+ * @type {boolean}
259
+ */
260
+ /**
261
+ * The raw transaction response object. It is populated after
262
+ * {@link Snapshot#begin} is called.
263
+ *
264
+ * @name Snapshot#metadata
265
+ * @type {?TransactionResponse}
266
+ */
267
+ /**
268
+ * **Snapshot only**
269
+ * The timestamp at which all reads are performed.
270
+ *
271
+ * @name Snapshot#readTimestamp
272
+ * @type {?external:PreciseDate}
273
+ */
274
+ /**
275
+ * **Snapshot only**
276
+ * The protobuf version of {@link Snapshot#readTimestamp}. This is useful if
277
+ * you require microsecond precision.
278
+ *
279
+ * @name Snapshot#readTimestampProto
280
+ * @type {?google.protobuf.Timestamp}
281
+ */
282
+ /**
283
+ * @constructor
284
+ *
285
+ * @param {Session} session The parent Session object.
286
+ * @param {TimestampBounds} [options] Snapshot timestamp bounds.
287
+ * @param {QueryOptions} [queryOptions] Default query options to use when none
288
+ * are specified for a query.
289
+ */
290
+ constructor(session: Session, options?: TimestampBounds, queryOptions?: IQueryOptions);
291
+ /**
292
+ * @typedef {object} TransactionResponse
293
+ * @property {string|Buffer} id The transaction ID.
294
+ * @property {?google.protobuf.Timestamp} readTimestamp For snapshot read-only
295
+ * transactions, the read timestamp chosen for the transaction.
296
+ */
297
+ /**
298
+ * @typedef {array} TransactionBeginResponse
299
+ * @property {TransactionResponse} 0 The raw transaction object.
300
+ */
301
+ /**
302
+ * @callback TransactionBeginCallback
303
+ * @param {?Error} err Request error, if any.
304
+ * @param {TransactionResponse} apiResponse The raw transaction object.
305
+ */
306
+ /**
307
+ * Begin a new transaction. Typically, you need not call this unless
308
+ * manually creating transactions via {@link Session} objects.
309
+ *
310
+ * @see [BeginTransaction API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.BeginTransaction)
311
+ *
312
+ * @param {object} [gaxOptions] Request configuration options,
313
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
314
+ * for more details.
315
+ * @param {TransactionBeginCallback} [callback] Callback function.
316
+ * @returns {Promise<TransactionBeginResponse>}
317
+ *
318
+ * @example
319
+ * ```
320
+ * transaction.begin(function(err) {
321
+ * if (!err) {
322
+ * // transaction began successfully.
323
+ * }
324
+ * });
325
+ *
326
+ * ```
327
+ * @example If the callback is omitted, the function returns a Promise
328
+ * ```
329
+ * transaction.begin()
330
+ * .then(function(data) {
331
+ * const apiResponse = data[0];
332
+ * });
333
+ * ```
334
+ */
335
+ begin(gaxOptions?: CallOptions): Promise<BeginResponse>;
336
+ begin(callback: BeginTransactionCallback): void;
337
+ begin(gaxOptions: CallOptions, callback: BeginTransactionCallback): void;
338
+ /**
339
+ * A KeyRange represents a range of rows in a table or index.
340
+ *
341
+ * A range has a start key and an end key. These keys can be open or closed,
342
+ * indicating if the range includes rows with that key.
343
+ *
344
+ * Keys are represented by an array of strings where the nth value in the list
345
+ * corresponds to the nth component of the table or index primary key.
346
+ *
347
+ * @typedef {object} KeyRange
348
+ * @property {string[]} [startClosed] If the start is closed, then the range
349
+ * includes all rows whose first key columns exactly match.
350
+ * @property {string[]} [startOpen] If the start is open, then the range
351
+ * excludes rows whose first key columns exactly match.
352
+ * @property {string[]} [endClosed] If the end is closed, then the range
353
+ * includes all rows whose first key columns exactly match.
354
+ * @property {string[]} [endOpen] If the end is open, then the range excludes
355
+ * rows whose first key columns exactly match.
356
+ */
357
+ /**
358
+ * Read request options. This includes all standard ReadRequest options as
359
+ * well as several convenience properties.
360
+ *
361
+ * @see [StreamingRead API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.StreamingRead)
362
+ * @see [ReadRequest API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ReadRequest)
363
+ *
364
+ * @typedef {object} ReadRequest
365
+ * @property {string} table The name of the table in the database to be read.
366
+ * @property {string[]} columns The columns of the table to be returned for each
367
+ * row matching this query.
368
+ * @property {string[]|string[][]} keys The primary or index keys of the rows in this table to be
369
+ * yielded. If using a composite key, provide an array within this array.
370
+ * See the example below.
371
+ * @property {KeyRange[]} [ranges] An alternative to the keys property; this can
372
+ * be used to define a range of keys to be yielded.
373
+ * @property {string} [index] The name of an index on the table if a
374
+ * different index than the primary key should be used to determine which rows to return.
375
+ * @property {boolean} [json=false] Receive the rows as serialized objects. This
376
+ * is the equivalent of calling `toJSON()` on each row.
377
+ * @property {JSONOptions} [jsonOptions] Configuration options for the serialized
378
+ * objects.
379
+ * @property {object} [keySet] Defines a collection of keys and/or key ranges to
380
+ * read.
381
+ * @property {number} [limit] The number of rows to yield.
382
+ * @property {Buffer} [partitionToken]
383
+ * If present, results will be restricted to the specified partition
384
+ * previously created using PartitionRead(). There must be an exact
385
+ * match for the values of fields common to this message and the
386
+ * PartitionReadRequest message used to create this partition_token.
387
+ * @property {google.spanner.v1.RequestOptions} [requestOptions]
388
+ * Common options for this request.
389
+ * @property {google.spanner.v1.IDirectedReadOptions} [directedReadOptions]
390
+ * Indicates which replicas or regions should be used for non-transactional reads or queries.
391
+ * @property {object} [gaxOptions]
392
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
393
+ * for more details.
394
+ */
395
+ /**
396
+ * Create a readable object stream to receive rows from the database using key
397
+ * lookups and scans.
398
+ *
399
+ * Wrapper around {@link v1.SpannerClient#streamingRead}.
400
+ *
401
+ * @see {@link v1.SpannerClient#streamingRead}
402
+ * @see [StreamingRead API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.StreamingRead)
403
+ * @see [ReadRequest API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ReadRequest)
404
+ *
405
+ * @fires PartialResultStream#response
406
+ * @fires PartialResultStream#stats
407
+ *
408
+ * @param {string} table The table to read from.
409
+ * @param {ReadRequest} query Configuration object. See official
410
+ * [`ReadRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ReadRequest).
411
+ * API documentation.
412
+ * @returns {ReadableStream} A readable stream that emits rows.
413
+ *
414
+ * @example
415
+ * ```
416
+ * transaction.createReadStream('Singers', {
417
+ * keys: ['1'],
418
+ * columns: ['SingerId', 'name']
419
+ * })
420
+ * .on('error', function(err) {})
421
+ * .on('data', function(row) {
422
+ * // row = [
423
+ * // {
424
+ * // name: 'SingerId',
425
+ * // value: '1'
426
+ * // },
427
+ * // {
428
+ * // name: 'Name',
429
+ * // value: 'Eddie Wilson'
430
+ * // }
431
+ * // ]
432
+ * })
433
+ * .on('end', function() {
434
+ * // All results retrieved.
435
+ * });
436
+ *
437
+ * ```
438
+ * @example Provide an array for `query.keys` to read with a
439
+ * composite key.
440
+ * ```
441
+ * const query = {
442
+ * keys: [
443
+ * [
444
+ * 'Id1',
445
+ * 'Name1'
446
+ * ],
447
+ * [
448
+ * 'Id2',
449
+ * 'Name2'
450
+ * ]
451
+ * ],
452
+ * // ...
453
+ * };
454
+ * ```
455
+ *
456
+ * @example Rows are returned as an array of object arrays. Each
457
+ * object has a `name` and `value` property. To get a serialized object, call
458
+ * `toJSON()`.
459
+ * ```
460
+ * transaction.createReadStream('Singers', {
461
+ * keys: ['1'],
462
+ * columns: ['SingerId', 'name']
463
+ * })
464
+ * .on('error', function(err) {})
465
+ * .on('data', function(row) {
466
+ * // row.toJSON() = {
467
+ * // SingerId: '1',
468
+ * // Name: 'Eddie Wilson'
469
+ * // }
470
+ * })
471
+ * .on('end', function() {
472
+ * // All results retrieved.
473
+ * });
474
+ * ```
475
+ *
476
+ * @example Alternatively, set `query.json` to `true`, and this step
477
+ * will perform automatically.
478
+ * ```
479
+ * transaction.createReadStream('Singers', {
480
+ * keys: ['1'],
481
+ * columns: ['SingerId', 'name'],
482
+ * json: true,
483
+ * })
484
+ * .on('error', function(err) {})
485
+ * .on('data', function(row) {
486
+ * // row = {
487
+ * // SingerId: '1',
488
+ * // Name: 'Eddie Wilson'
489
+ * // }
490
+ * })
491
+ * .on('end', function() {
492
+ * // All results retrieved.
493
+ * });
494
+ * ```
495
+ *
496
+ * @example If you anticipate many results, you can end a stream
497
+ * early to prevent unnecessary processing and API requests.
498
+ * ```
499
+ * transaction.createReadStream('Singers', {
500
+ * keys: ['1'],
501
+ * columns: ['SingerId', 'name']
502
+ * })
503
+ * .on('data', function(row) {
504
+ * this.end();
505
+ * });
506
+ * ```
507
+ */
508
+ createReadStream(table: string, request?: ReadRequest): PartialResultStream;
509
+ /**
510
+ * Let the client know you're done with a particular transaction. This should
511
+ * mainly be called for {@link Snapshot} objects, however in certain cases
512
+ * you may want to call them for {@link Transaction} objects as well.
513
+ *
514
+ * @example Calling `end` on a read only snapshot
515
+ * ```
516
+ * database.getSnapshot((err, transaction) => {
517
+ * if (err) {
518
+ * // Error handling omitted.
519
+ * }
520
+ *
521
+ * transaction.run('SELECT * FROM Singers', (err, rows) => {
522
+ * if (err) {
523
+ * // Error handling omitted.
524
+ * }
525
+ *
526
+ * // End the snapshot.
527
+ * transaction.end();
528
+ * });
529
+ * });
530
+ * ```
531
+ *
532
+ * @example Calling `end` on a read/write transaction
533
+ * ```
534
+ * database.runTransaction((err, transaction) => {
535
+ * if (err) {
536
+ * // Error handling omitted.
537
+ * }
538
+ *
539
+ * const query = 'UPDATE Account SET Balance = 1000 WHERE Key = 1';
540
+ *
541
+ * transaction.runUpdate(query, err => {
542
+ * if (err) {
543
+ * // In the event of an error, there would be nothing to rollback,
544
+ * so
545
+ * // instead of continuing, discard the
546
+ * transaction. transaction.end(); return;
547
+ * }
548
+ *
549
+ * transaction.commit(err => {});
550
+ * });
551
+ * });
552
+ * ```
553
+ */
554
+ end(): void;
555
+ /**
556
+ * @typedef {array} ReadResponse
557
+ * @property {array[]} 0 Rows are returned as an array of object arrays. Each
558
+ * object has a `name` and `value` property. To get a serialized object,
559
+ * call `toJSON()`. Optionally, provide an options object to `toJSON()`
560
+ * specifying `wrapNumbers: true` to protect large integer values outside
561
+ * of the range of JavaScript Number. If set, FLOAT64 values are returned
562
+ * as {@link Spanner.Float} objects and INT64 values as {@link
563
+ * Spanner.Int}.
564
+ */
565
+ /**
566
+ * @callback ReadCallback
567
+ * @param {?Error} err Request error, if any.
568
+ * @param {array[]} rows Rows are returned as an array of object arrays. Each
569
+ * object has a `name` and `value` property. To get a serialized object,
570
+ * call `toJSON()`. Optionally, provide an options object to `toJSON()`
571
+ * specifying `wrapNumbers: true` to protect large integer values outside
572
+ * of the range of JavaScript Number. If set, FLOAT64 values are returned
573
+ * as {@link Spanner.Float} objects and INT64 values as {@link
574
+ * Spanner.Int}.
575
+ */
576
+ /**
577
+ * Performs a read request against the specified Table.
578
+ *
579
+ * Wrapper around {@link v1.SpannerClient#read}.
580
+ *
581
+ * @see {@link v1.SpannerClient#read}
582
+ *
583
+ * @param {string} table The table to read from.
584
+ * @param {ReadRequest} query Configuration object. See official
585
+ * [`ReadRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ReadRequest).
586
+ * API documentation.
587
+ * @param {ReadCallback} [callback] Callback function.
588
+ * @returns {Promise<ReadResponse>}
589
+ *
590
+ * @example
591
+ * ```
592
+ * const query = {
593
+ * keys: ['1'],
594
+ * columns: ['SingerId', 'name']
595
+ * };
596
+ *
597
+ * transaction.read('Singers', query, function(err, rows) {
598
+ * if (err) {
599
+ * // Error handling omitted.
600
+ * }
601
+ *
602
+ * const firstRow = rows[0];
603
+ *
604
+ * // firstRow = [
605
+ * // {
606
+ * // name: 'SingerId',
607
+ * // value: '1'
608
+ * // },
609
+ * // {
610
+ * // name: 'Name',
611
+ * // value: 'Eddie Wilson'
612
+ * // }
613
+ * // ]
614
+ * });
615
+ *
616
+ * ```
617
+ * @example Provide an array for `query.keys` to read with a
618
+ * composite key.
619
+ * ```
620
+ * const query = {
621
+ * keys: [
622
+ * [
623
+ * 'Id1',
624
+ * 'Name1'
625
+ * ],
626
+ * [
627
+ * 'Id2',
628
+ * 'Name2'
629
+ * ]
630
+ * ],
631
+ * // ...
632
+ * };
633
+ * ```
634
+ *
635
+ * @example Rows are returned as an array of object arrays. Each
636
+ * object has a `name` and `value` property. To get a serialized object, call
637
+ * `toJSON()`.
638
+ * ```
639
+ * transaction.read('Singers', query, function(err, rows) {
640
+ * if (err) {
641
+ * // Error handling omitted.
642
+ * }
643
+ *
644
+ * const firstRow = rows[0];
645
+ *
646
+ * // firstRow.toJSON() = {
647
+ * // SingerId: '1',
648
+ * // Name: 'Eddie Wilson'
649
+ * // }
650
+ * });
651
+ * ```
652
+ *
653
+ * @example Alternatively, set `query.json` to `true`, and this step
654
+ * will perform automatically.
655
+ * ```
656
+ * query.json = true;
657
+ *
658
+ * transaction.read('Singers', query, function(err, rows) {
659
+ * if (err) {
660
+ * // Error handling omitted.
661
+ * }
662
+ *
663
+ * const firstRow = rows[0];
664
+ *
665
+ * // firstRow = {
666
+ * // SingerId: '1',
667
+ * // Name: 'Eddie Wilson'
668
+ * // }
669
+ * });
670
+ * ```
671
+ */
672
+ read(table: string, request: ReadRequest): Promise<ReadResponse>;
673
+ read(table: string, callback: ReadCallback): void;
674
+ read(table: string, request: ReadRequest, callback: ReadCallback): void;
675
+ /**
676
+ * Execute a SQL statement on this database inside of a transaction.
677
+ *
678
+ * **Performance Considerations:**
679
+ *
680
+ * This method wraps the streaming method,
681
+ * {@link Snapshot#run} for your convenience. All rows are stored in memory
682
+ * before releasing to your callback. If you intend to receive a lot of
683
+ * results from your query, consider using the streaming method,
684
+ * so you can free each result from memory after consuming it.
685
+ *
686
+ * Wrapper around {@link v1.SpannerClient#executeStreamingSql}.
687
+ *
688
+ * @see {@link v1.SpannerClient#executeStreamingSql}
689
+ * @see [ExecuteStreamingSql API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ExecuteStreamingSql)
690
+ * @see [ExecuteSqlRequest API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
691
+ *
692
+ * @param {string|ExecuteSqlRequest} query A SQL query or
693
+ * {@link ExecuteSqlRequest} object.
694
+ * @param {RunCallback} [callback] Callback function.
695
+ * @returns {Promise<RunResponse>}
696
+ *
697
+ * @example
698
+ * ```
699
+ * transaction.run(query, function(err, rows) {
700
+ * if (err) {
701
+ * // Error handling omitted.
702
+ * }
703
+ *
704
+ * // rows = [
705
+ * // {
706
+ * // SingerId: '1',
707
+ * // Name: 'Eddie Wilson'
708
+ * // }
709
+ * // ]
710
+ * });
711
+ *
712
+ * ```
713
+ * @example The SQL query string can contain parameter placeholders.
714
+ * A parameter placeholder consists of '@' followed by the parameter name.
715
+ * ```
716
+ * const query = {
717
+ * sql: 'SELECT * FROM Singers WHERE name = @name',
718
+ * params: {
719
+ * name: 'Eddie Wilson'
720
+ * }
721
+ * };
722
+ *
723
+ * transaction.run(query, function(err, rows) {
724
+ * if (err) {
725
+ * // Error handling omitted.
726
+ * }
727
+ * });
728
+ * ```
729
+ *
730
+ * @example If you need to enforce a specific param type, a types map
731
+ * can be provided. This is typically useful if your param value can be null.
732
+ * ```
733
+ * const query = {
734
+ * sql: 'SELECT * FROM Singers WHERE name = @name AND id = @id',
735
+ * params: {
736
+ * id: spanner.int(8),
737
+ * name: null
738
+ * },
739
+ * types: {
740
+ * id: 'int64',
741
+ * name: 'string'
742
+ * }
743
+ * };
744
+ *
745
+ * transaction.run(query, function(err, rows) {
746
+ * if (err) {
747
+ * // Error handling omitted.
748
+ * }
749
+ * });
750
+ * ```
751
+ */
752
+ run(query: string | ExecuteSqlRequest): Promise<RunResponse>;
753
+ run(query: string | ExecuteSqlRequest, callback: RunCallback): void;
754
+ /**
755
+ * ExecuteSql request options. This includes all standard ExecuteSqlRequest
756
+ * options as well as several convenience properties.
757
+ *
758
+ * @see [Query Syntax](https://cloud.google.com/spanner/docs/query-syntax)
759
+ * @see [ExecuteSql API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ExecuteSql)
760
+ *
761
+ * @typedef {object} ExecuteSqlRequest
762
+ * @property {string} resumeToken The token used to resume getting results.
763
+ * @property {google.spanner.v1.ExecuteSqlRequest.QueryMode} queryMode Query plan and
764
+ * execution statistics for the SQL statement that
765
+ * produced this result set.
766
+ * @property {string} partitionToken The partition token.
767
+ * @property {number} seqno The Sequence number. This option is used internally and will be overridden.
768
+ * @property {string} sql The SQL string.
769
+ * @property {google.spanner.v1.ExecuteSqlRequest.IQueryOptions} [queryOptions]
770
+ * Default query options to use with the database. These options will be
771
+ * overridden by any query options set in environment variables or that
772
+ * are specified on a per-query basis.
773
+ * @property {google.spanner.v1.IRequestOptions} requestOptions The request options to include
774
+ * with the commit request.
775
+ * @property {Object.<string, *>} [params] A map of parameter names to values.
776
+ * @property {Object.<string, (string|ParamType)>} [types] A map of parameter
777
+ * names to types. If omitted the client will attempt to guess for all
778
+ * non-null values.
779
+ * @property {boolean} [json=false] Receive the rows as serialized objects. This
780
+ * is the equivalent of calling `toJSON()` on each row.
781
+ * @property {JSONOptions} [jsonOptions] Configuration options for the
782
+ * serialized objects.
783
+ * @property {object} [gaxOptions] Request configuration options,
784
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
785
+ * for more details.
786
+ * @property {number} [maxResumeRetries] The maximum number of times that the
787
+ * stream will retry to push data downstream, when the downstream indicates
788
+ * that it is not ready for any more data. Increase this value if you
789
+ * experience 'Stream is still not ready to receive data' errors as a
790
+ * result of a slow writer in your receiving stream.
791
+ * @property {object} [directedReadOptions]
792
+ * Indicates which replicas or regions should be used for non-transactional reads or queries.
793
+ */
794
+ /**
795
+ * Create a readable object stream to receive resulting rows from a SQL
796
+ * statement.
797
+ *
798
+ * Wrapper around {@link v1.SpannerClient#executeStreamingSql}.
799
+ *
800
+ * @see {@link v1.SpannerClient#executeStreamingSql}
801
+ * @see [ExecuteStreamingSql API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ExecuteStreamingSql)
802
+ * @see [ExecuteSqlRequest API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
803
+ *
804
+ * @fires PartialResultStream#response
805
+ * @fires PartialResultStream#stats
806
+ *
807
+ * @param {string|ExecuteSqlRequest} query A SQL query or
808
+ * {@link ExecuteSqlRequest} object.
809
+ * @returns {ReadableStream}
810
+ *
811
+ * @example
812
+ * ```
813
+ * const query = 'SELECT * FROM Singers';
814
+ *
815
+ * transaction.runStream(query)
816
+ * .on('error', function(err) {})
817
+ * .on('data', function(row) {
818
+ * // row = {
819
+ * // SingerId: '1',
820
+ * // Name: 'Eddie Wilson'
821
+ * // }
822
+ * })
823
+ * .on('end', function() {
824
+ * // All results retrieved.
825
+ * });
826
+ *
827
+ * ```
828
+ * @example The SQL query string can contain parameter placeholders.
829
+ * A parameter placeholder consists of '@' followed by the parameter name.
830
+ * ```
831
+ * const query = {
832
+ * sql: 'SELECT * FROM Singers WHERE name = @name',
833
+ * params: {
834
+ * name: 'Eddie Wilson'
835
+ * }
836
+ * };
837
+ *
838
+ * transaction.runStream(query)
839
+ * .on('error', function(err) {})
840
+ * .on('data', function(row) {})
841
+ * .on('end', function() {});
842
+ * ```
843
+ *
844
+ * @example If you anticipate many results, you can end a stream
845
+ * early to prevent unnecessary processing and API requests.
846
+ * ```
847
+ * transaction.runStream(query)
848
+ * .on('data', function(row) {
849
+ * this.end();
850
+ * });
851
+ * ```
852
+ */
853
+ runStream(query: string | ExecuteSqlRequest): PartialResultStream;
854
+ /**
855
+ *
856
+ * @private
857
+ */
858
+ configureTagOptions(singleUse?: boolean, transactionTag?: string, requestOptions?: {}): IRequestOptions | null;
859
+ /**
860
+ * Transforms convenience options `keys` and `ranges` into a KeySet object.
861
+ *
862
+ * @private
863
+ * @static
864
+ *
865
+ * @param {ReadRequest} request The read request.
866
+ * @returns {object}
867
+ */
868
+ static encodeKeySet(request: ReadRequest): spannerClient.spanner.v1.IKeySet;
869
+ /**
870
+ * Formats timestamp options into proto format.
871
+ *
872
+ * @private
873
+ * @static
874
+ *
875
+ * @param {TimestampBounds} options The user supplied options.
876
+ * @returns {object}
877
+ */
878
+ static encodeTimestampBounds(options: TimestampBounds): spannerClient.spanner.v1.TransactionOptions.IReadOnly;
879
+ /**
880
+ * Encodes convenience options `param` and `types` into the proto formatted.
881
+ *
882
+ * @private
883
+ * @static
884
+ *
885
+ * @param {ExecuteSqlRequest} request The SQL request.
886
+ * @returns {object}
887
+ */
888
+ static encodeParams(request: ExecuteSqlRequest): {
889
+ params: p.IStruct;
890
+ paramTypes: {
891
+ [field: string]: spannerClient.spanner.v1.Type;
892
+ };
893
+ };
894
+ /**
895
+ * Get directed read options
896
+ * @private
897
+ * @param {google.spanner.v1.IDirectedReadOptions} directedReadOptions Request directedReadOptions object.
898
+ */
899
+ protected _getDirectedReadOptions(directedReadOptions: google.spanner.v1.IDirectedReadOptions | null | undefined): spannerClient.spanner.v1.IDirectedReadOptions | null | undefined;
900
+ /**
901
+ * Update transaction properties from the response.
902
+ *
903
+ * @private
904
+ *
905
+ * @param {spannerClient.spanner.v1.ITransaction} resp Response object.
906
+ */
907
+ protected _update(resp: spannerClient.spanner.v1.ITransaction): void;
908
+ /**
909
+ * Wrap `makeRequest` function with the lock to make sure the inline begin
910
+ * transaction can happen only once.
911
+ *
912
+ * @param makeRequest
913
+ * @private
914
+ */
915
+ private _wrapWithIdWaiter;
916
+ _releaseWaitingRequests(): void;
917
+ /**
918
+ * Gets the Spanner object
919
+ *
920
+ * @private
921
+ *
922
+ * @returns {Spanner}
923
+ */
924
+ protected _getSpanner(): Spanner;
925
+ }
926
+ /**
927
+ * Never use DML class directly. Instead, it should be extended upon
928
+ * if a class requires DML capabilities.
929
+ *
930
+ * @private
931
+ * @class
932
+ */
933
+ export declare class Dml extends Snapshot {
934
+ /**
935
+ * @typedef {array} RunUpdateResponse
936
+ * @property {number} 0 Affected row count.
937
+ */
938
+ /**
939
+ * @callback RunUpdateCallback
940
+ * @param {?Error} err Request error, if any.
941
+ * @param {number} rowCount Affected row count.
942
+ */
943
+ /**
944
+ * Execute a DML statement and get the affected row count.
945
+ *
946
+ * @private
947
+ *
948
+ * @see {@link Transaction#run}
949
+ *
950
+ * @param {string|object} query A DML statement or
951
+ * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
952
+ * object.
953
+ * @param {object} [query.params] A map of parameter name to values.
954
+ * @param {object} [query.types] A map of parameter types.
955
+ * @param {RunUpdateCallback} [callback] Callback function.
956
+ * @returns {Promise<RunUpdateResponse>}
957
+ */
958
+ runUpdate(query: string | ExecuteSqlRequest): Promise<RunUpdateResponse>;
959
+ runUpdate(query: string | ExecuteSqlRequest, callback: RunUpdateCallback): void;
960
+ }
961
+ /**
962
+ * This type of transaction is the only way to write data into Cloud Spanner.
963
+ * These transactions rely on pessimistic locking and, if necessary, two-phase
964
+ * commit. Locking read-write transactions may abort, requiring the application
965
+ * to retry.
966
+ *
967
+ * Calling either {@link Transaction#commit} or {@link Transaction#rollback}
968
+ * signals that the transaction is finished and no further requests will be
969
+ * made. If for some reason you decide not to call one of the aformentioned
970
+ * methods, call {@link Transaction#end} to release the underlying
971
+ * {@link Session}.
972
+ *
973
+ * Running a transaction via {@link Database#runTransaction} or
974
+ * {@link Database#runTransactionAsync} automatically re-runs the
975
+ * transaction on `ABORTED` errors.
976
+ *
977
+ * {@link Database#getTransaction} returns a plain {@link Transaction}
978
+ * object, requiring the user to retry manually.
979
+ *
980
+ * @class
981
+ * @extends Snapshot
982
+ *
983
+ * @param {Session} session The parent Session object.
984
+ *
985
+ * @example
986
+ * ```
987
+ * const {Spanner} = require('@google-cloud/spanner');
988
+ * const spanner = new Spanner();
989
+ *
990
+ * const instance = spanner.instance('my-instance');
991
+ * const database = instance.database('my-database');
992
+ *
993
+ * database.runTransaction(function(err, transaction) {
994
+ * // The `transaction` object is ready for use.
995
+ * });
996
+ *
997
+ * ```
998
+ * @example To manually control retrying the transaction, use the
999
+ * `getTransaction` method.
1000
+ * ```
1001
+ * database.getTransaction(function(err, transaction) {
1002
+ * // The `transaction` object is ready for use.
1003
+ * });
1004
+ * ```
1005
+ */
1006
+ export declare class Transaction extends Dml {
1007
+ commitTimestamp?: PreciseDate;
1008
+ commitTimestampProto?: spannerClient.protobuf.ITimestamp;
1009
+ private _queuedMutations;
1010
+ /**
1011
+ * Timestamp at which the transaction was committed. Will be populated once
1012
+ * {@link Transaction#commit} is called.
1013
+ *
1014
+ * @name Transaction#commitTimestamp
1015
+ * @type {?external:PreciseDate}
1016
+ */
1017
+ /**
1018
+ * The protobuf version of {@link Transaction#commitTimestamp}. This is useful
1019
+ * if you require microsecond precision.
1020
+ *
1021
+ * @name Transaction#commitTimestampProto
1022
+ * @type {?google.protobuf.Timestamp}
1023
+ */
1024
+ /**
1025
+ * Execute a DML statement and get the affected row count.
1026
+ *
1027
+ * @name Transaction#runUpdate
1028
+ *
1029
+ * @see {@link Transaction#run}
1030
+ *
1031
+ * @param {string|object} query A DML statement or
1032
+ * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
1033
+ * object.
1034
+ * @param {object} [query.params] A map of parameter name to values.
1035
+ * @param {object} [query.types] A map of parameter types.
1036
+ * @param {RunUpdateCallback} [callback] Callback function.
1037
+ * @returns {Promise<RunUpdateResponse>}
1038
+ *
1039
+ * @example
1040
+ * ```
1041
+ * const query = 'UPDATE Account SET Balance = 1000 WHERE Key = 1';
1042
+ *
1043
+ * transaction.runUpdate(query, (err, rowCount) => {
1044
+ * if (err) {
1045
+ * // Error handling omitted.
1046
+ * }
1047
+ * });
1048
+ * ```
1049
+ */
1050
+ constructor(session: Session, options?: spannerClient.spanner.v1.TransactionOptions.ReadWrite, queryOptions?: IQueryOptions, requestOptions?: Pick<IRequestOptions, 'transactionTag'>);
1051
+ /**
1052
+ * @typedef {error} BatchUpdateError
1053
+ * @property {number} code gRPC status code.
1054
+ * @property {?object} metadata gRPC metadata.
1055
+ * @property {number[]} rowCounts The affected row counts for any DML
1056
+ * statements that were executed successfully before this error occurred.
1057
+ */
1058
+ /**
1059
+ * @typedef {object} BatchUpdateOptions
1060
+ * @property {object} [gaxOptions] Request configuration options,
1061
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1062
+ * for more details.
1063
+ * @property {google.spanner.v1.IRequestOptions} [requestOptions] The request options to include
1064
+ * with the commit request.
1065
+ */
1066
+ /**
1067
+ * @typedef {array} BatchUpdateResponse
1068
+ * @property {number[]} 0 Affected row counts.
1069
+ * @property {object} 1 The full API response.
1070
+ */
1071
+ /**
1072
+ * @callback BatchUpdateCallback
1073
+ * @param {?BatchUpdateError} err Request error, if any.
1074
+ * @param {number[]} rowCounts Affected row counts.
1075
+ * @param {object} apiResponse The full API response.
1076
+ */
1077
+ /**
1078
+ * Execute a series of DML statements and get the affected row counts.
1079
+ *
1080
+ * If any of the DML statements fail, the returned error will contain a list
1081
+ * of results for all successfully executed statements.
1082
+ *
1083
+ * @param {string[]|object[]} query A DML statement or
1084
+ * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
1085
+ * object.
1086
+ * @param {object} [query.params] A map of parameter name to values.
1087
+ * @param {object} [query.types] A map of parameter types.
1088
+ * @param {object} [gaxOptions] Request configuration options,
1089
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1090
+ * for more details.
1091
+ * @param {BatchUpdateOptions} [options] Options for configuring the request.
1092
+ * @param {RunUpdateCallback} [callback] Callback function.
1093
+ * @returns {Promise<RunUpdateResponse>}
1094
+ *
1095
+ * @example
1096
+ * ```
1097
+ * const queries = [
1098
+ * {
1099
+ * sql: 'INSERT INTO MyTable (Key, Value) VALUES (@key, @value)',
1100
+ * params: {key: 'my-key', value: 'my-value'},
1101
+ * },
1102
+ * {
1103
+ * sql: 'UPDATE MyTable t SET t.Value = @value WHERE t.KEY = @key',
1104
+ * params: {key: 'my-other-key', value: 'my-other-value'}
1105
+ * }
1106
+ * ];
1107
+ *
1108
+ * transaction.batchUpdate(queries, (err, rowCounts, apiResponse) => {
1109
+ * if (err) {
1110
+ * // Error handling omitted.
1111
+ * }
1112
+ * });
1113
+ *
1114
+ * ```
1115
+ * @example If the callback is omitted, we'll return a Promise.
1116
+ * ```
1117
+ * const [rowCounts, apiResponse] = await transaction.batchUpdate(queries);
1118
+ * ```
1119
+ */
1120
+ batchUpdate(queries: Array<string | Statement>, options?: BatchUpdateOptions | CallOptions): Promise<BatchUpdateResponse>;
1121
+ batchUpdate(queries: Array<string | Statement>, callback: BatchUpdateCallback): void;
1122
+ batchUpdate(queries: Array<string | Statement>, options: BatchUpdateOptions | CallOptions, callback: BatchUpdateCallback): void;
1123
+ private static extractKnownMetadata;
1124
+ /**
1125
+ * This method updates the _queuedMutations property of the transaction.
1126
+ *
1127
+ * @public
1128
+ *
1129
+ * @param {spannerClient.spanner.v1.Mutation[]} [mutation]
1130
+ */
1131
+ setQueuedMutations(mutation: spannerClient.spanner.v1.Mutation[]): void;
1132
+ /**
1133
+ * @typedef {object} CommitOptions
1134
+ * @property {google.spanner.v1.IRequestOptions} requestOptions The request options to include
1135
+ * with the commit request.
1136
+ * @property {boolean} returnCommitStats Include statistics related to the
1137
+ * transaction in the {@link CommitResponse}.
1138
+ * @property {spannerClient.proto.IDuration} maxCommitDelay Maximum amount
1139
+ * of delay the commit is willing to incur in order to improve
1140
+ * throughput. Value should be between 0ms and 500ms.
1141
+ * @property {object} [gaxOptions] The request configuration options,
1142
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1143
+ * for more details.
1144
+ */
1145
+ /**
1146
+ * @typedef {object} CommitResponse
1147
+ * @property {google.protobuf.Timestamp} commitTimestamp The transaction
1148
+ * commit timestamp.
1149
+ * @property {google.spanner.v1.CommitResponse.ICommitStats|null} commitStats
1150
+ * The statistics about this commit. Only populated if requested in
1151
+ * {@link CommitOptions}.
1152
+ */
1153
+ /**
1154
+ * @typedef {array} CommitPromiseResponse
1155
+ * @property {CommitResponse} 0 The commit response.
1156
+ */
1157
+ /**
1158
+ * @callback CommitCallback
1159
+ * @param {?Error} error Request error, if any.
1160
+ * @param {CommitResponse} apiResponse The full API response.
1161
+ */
1162
+ /**
1163
+ * Commit the transaction.
1164
+ *
1165
+ * Wrapper around {@link v1.SpannerClient#commit}.
1166
+ *
1167
+ * @see {@link v1.SpannerClient#commit}
1168
+ * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
1169
+ *
1170
+ * @param {CommitOptions} [options] Options for configuring the request.
1171
+ * @param {CommitCallback} [callback] Callback function.
1172
+ * @returns {Promise<CommitPromiseResponse>}
1173
+ *
1174
+ * @example
1175
+ * ```
1176
+ * database.runTransaction(function(err, transaction) {
1177
+ * if (err) {
1178
+ * // Error handling omitted.
1179
+ * }
1180
+ *
1181
+ * // Queue a mutation (note that there is no callback passed to `insert`).
1182
+ * transaction.insert('Singers', {
1183
+ * SingerId: 'Id3b',
1184
+ * Name: 'Joe West'
1185
+ * });
1186
+ *
1187
+ * // Commit the transaction.
1188
+ * transaction.commit(function(err, apiResponse) {
1189
+ * if (!err) {
1190
+ * // Get the commit timestamp on successful commits.
1191
+ * const {commitTimestamp} = apiResponse;
1192
+ * }
1193
+ * });
1194
+ * });
1195
+ * ```
1196
+ */
1197
+ commit(options?: CommitOptions | CallOptions): Promise<CommitResponse>;
1198
+ commit(callback: CommitCallback): void;
1199
+ commit(options: CommitOptions | CallOptions, callback: CommitCallback): void;
1200
+ /**
1201
+ * Decorates an error returned by a commit with additional information for
1202
+ * specific known errors.
1203
+ * @param err the error to check and decorate with additional information if possible
1204
+ * @param mutations the mutations included in the commit request
1205
+ * @private
1206
+ */
1207
+ private static decorateCommitError;
1208
+ /**
1209
+ * Decorates an error returned by a commit with additional information if the
1210
+ * error was returned because the application tried to insert an array of
1211
+ * objects into a JSON column. An array of objects will by default be encoded
1212
+ * as ARRAY<JSON>, but can also be interpreted as JSON. An application must
1213
+ * specify a top-level array of objects that should be inserted into a JSON
1214
+ * column as a string instead of as an array of objects.
1215
+ * @param err the error returned by the commit RPC
1216
+ * @param mutations the mutations included in the commit request
1217
+ * @private
1218
+ */
1219
+ private static decoratePossibleJsonMismatchError;
1220
+ /**
1221
+ * Delete rows from a table.
1222
+ *
1223
+ * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
1224
+ *
1225
+ * @param {string} table The name of the table.
1226
+ * @param {array} keys The keys for the rows to delete. If using a
1227
+ * composite key, provide an array within this array. See the example
1228
+ * below.
1229
+ *
1230
+ * @example
1231
+ * ```
1232
+ * const keys = ['Id1', 'Id2', 'Id3'];
1233
+ *
1234
+ * database.runTransaction(function(err, transaction) {
1235
+ * if (err) {
1236
+ * // Error handling omitted.
1237
+ * }
1238
+ *
1239
+ * // Queue this mutation until later calling `commit`.
1240
+ * // Note that a callback is not passed to `deleteRows`.
1241
+ * transaction.deleteRows('Singers', keys);
1242
+ *
1243
+ * // Commit the transaction.
1244
+ * transaction.commit(function(err) {
1245
+ * if (!err) {
1246
+ * // The rows were deleted successfully.
1247
+ * }
1248
+ * });
1249
+ * });
1250
+ *
1251
+ * ```
1252
+ * @example Provide an array for `keys` to delete rows with a
1253
+ * composite key.
1254
+ * ```
1255
+ * const keys = [
1256
+ * [
1257
+ * 'Id1',
1258
+ * 'Name1'
1259
+ * ],
1260
+ * [
1261
+ * 'Id2',
1262
+ * 'Name2'
1263
+ * ]
1264
+ * ];
1265
+ * ```
1266
+ */
1267
+ deleteRows(table: string, keys: Key[]): void;
1268
+ /**
1269
+ * Insert rows of data into this table.
1270
+ *
1271
+ * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
1272
+ *
1273
+ * @param {string} table The name of the table.
1274
+ * @param {object|object[]} rows A map of names to values of data to insert
1275
+ * into this table.
1276
+ *
1277
+ * @example
1278
+ * ```
1279
+ * const row = {
1280
+ * SingerId: 'Id3',
1281
+ * Name: 'Eddie Wilson'
1282
+ * };
1283
+ *
1284
+ * database.runTransaction(function(err, transaction) {
1285
+ * if (err) {
1286
+ * // Error handling omitted.
1287
+ * }
1288
+ *
1289
+ * // Queue this mutation until later calling `commit`.
1290
+ * // Note that a callback is not passed to `insert`.
1291
+ * transaction.insert('Singers', row);
1292
+ *
1293
+ * // Commit the transaction.
1294
+ * transaction.commit(function(err) {
1295
+ * if (!err) {
1296
+ * // The row was inserted successfully.
1297
+ * }
1298
+ * });
1299
+ * });
1300
+ *
1301
+ * ```
1302
+ * @example Multiple rows can be inserted at once.
1303
+ * ```
1304
+ * const row2 = {
1305
+ * SingerId: 'Id3b',
1306
+ * Name: 'Joe West'
1307
+ * };
1308
+ *
1309
+ * database.runTransaction(function(err, transaction) {
1310
+ * if (err) {
1311
+ * // Error handling omitted.
1312
+ * }
1313
+ *
1314
+ * // Queue multiple mutations until later calling `commit`.
1315
+ * // Note that a callback is not passed to `insert`.
1316
+ * transaction.insert('Singers', [
1317
+ * row,
1318
+ * row2
1319
+ * ]);
1320
+ *
1321
+ * // Commit the transaction.
1322
+ * transaction.commit(function(err) {
1323
+ * if (!err) {
1324
+ * // The rows were inserted successfully.
1325
+ * }
1326
+ * });
1327
+ * });
1328
+ * ```
1329
+ */
1330
+ insert(table: string, rows: object | object[]): void;
1331
+ /**
1332
+ * Replace rows of data within a table.
1333
+ *
1334
+ * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
1335
+ *
1336
+ * @param {string} table The table to read from.
1337
+ * @param {object|object[]} rows A map of names to values of data to insert
1338
+ * into this table.
1339
+ *
1340
+ * @example
1341
+ * ```
1342
+ * const row = {
1343
+ * SingerId: 'Id3',
1344
+ * Name: 'Joe West'
1345
+ * };
1346
+ *
1347
+ * database.runTransaction(function(err, transaction) {
1348
+ * if (err) {
1349
+ * // Error handling omitted.
1350
+ * }
1351
+ *
1352
+ * // Queue this mutation until later calling `commit`.
1353
+ * // Note that a callback is not passed to `replace`.
1354
+ * transaction.replace('Singers', row);
1355
+ *
1356
+ * // Commit the transaction.
1357
+ * transaction.commit(function(err) {
1358
+ * if (!err) {
1359
+ * // The row was replaced successfully.
1360
+ * }
1361
+ * });
1362
+ * });
1363
+ * ```
1364
+ */
1365
+ replace(table: string, rows: object | object[]): void;
1366
+ /**
1367
+ * Roll back a transaction, releasing any locks it holds. It is a good idea to
1368
+ * call this for any transaction that includes one or more queries that you
1369
+ * decide not to commit.
1370
+ *
1371
+ * Wrapper around {@link v1.SpannerClient#rollback}.
1372
+ *
1373
+ * @see {@link v1.SpannerClient#rollback}
1374
+ * @see [Rollback API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Rollback)
1375
+ *
1376
+ * @param {object} [gaxOptions] Request configuration options,
1377
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1378
+ * for more details.
1379
+ * @param {BasicCallback} [callback] Callback function.
1380
+ * @returns {Promise<BasicResponse>}
1381
+ *
1382
+ * @example
1383
+ * ```
1384
+ * database.runTransaction(function(err, transaction) {
1385
+ * if (err) {
1386
+ * // Error handling omitted.
1387
+ * }
1388
+ *
1389
+ * transaction.rollback(function(err) {
1390
+ * if (!err) {
1391
+ * // Transaction rolled back successfully.
1392
+ * }
1393
+ * });
1394
+ * });
1395
+ * ```
1396
+ */
1397
+ rollback(gaxOptions?: CallOptions): Promise<void>;
1398
+ rollback(callback: spannerClient.spanner.v1.Spanner.RollbackCallback): void;
1399
+ rollback(gaxOptions: CallOptions, callback: spannerClient.spanner.v1.Spanner.RollbackCallback): void;
1400
+ /**
1401
+ * Update rows of data within a table.
1402
+ *
1403
+ * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
1404
+ *
1405
+ * @param {string} table The table to read from.
1406
+ * @param {object|object[]} rows A map of names to values of data to insert
1407
+ * into this table.
1408
+ *
1409
+ * @example
1410
+ * ```
1411
+ * const row = {
1412
+ * SingerId: 'Id3',
1413
+ * Name: 'Joe West'
1414
+ * };
1415
+ *
1416
+ * database.runTransaction(function(err, transaction) {
1417
+ * if (err) {
1418
+ * // Error handling omitted.
1419
+ * }
1420
+ *
1421
+ * // Queue this mutation until later calling `commit`.
1422
+ * // Note that a callback is not passed to `update`.
1423
+ * transaction.update('Singers', row);
1424
+ *
1425
+ * // Commit the transaction.
1426
+ * transaction.commit(function(err) {
1427
+ * if (!err) {
1428
+ * // The row was updated successfully.
1429
+ * }
1430
+ * });
1431
+ * });
1432
+ * ```
1433
+ */
1434
+ update(table: string, rows: object | object[]): void;
1435
+ /**
1436
+ * Insert or update rows of data within a table.
1437
+ *
1438
+ * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
1439
+ *
1440
+ * @param {string} table The table to read from.
1441
+ * @param {object|object[]} rows A map of names to values of data to insert
1442
+ * into this table.
1443
+ *
1444
+ * @example
1445
+ * ```
1446
+ * const row = {
1447
+ * SingerId: 'Id3',
1448
+ * Name: 'Joe West'
1449
+ * };
1450
+ *
1451
+ * database.runTransaction(function(err, transaction) {
1452
+ * if (err) {
1453
+ * // Error handling omitted.
1454
+ * }
1455
+ *
1456
+ * // Queue this mutation until later calling `commit`.
1457
+ * // Note that a callback is not passed to `upsert`.
1458
+ * transaction.upsert('Singers', row);
1459
+ *
1460
+ * // Commit the transaction.
1461
+ * transaction.commit(function(err) {
1462
+ * if (!err) {
1463
+ * // The row was updated or inserted successfully.
1464
+ * }
1465
+ * });
1466
+ * });
1467
+ * ```
1468
+ */
1469
+ upsert(table: string, rows: object | object[]): void;
1470
+ /**
1471
+ * Formats the mutations.
1472
+ *
1473
+ * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
1474
+ *
1475
+ * @private
1476
+ *
1477
+ * @param {string} method CRUD method (insert, update, etc.).
1478
+ * @param {string} table Table to perform mutations in.
1479
+ * @param {object} rows Hash of key value pairs.
1480
+ */
1481
+ private _mutate;
1482
+ /**
1483
+ * Takes a list of rows and returns all unique column names.
1484
+ *
1485
+ * @private
1486
+ *
1487
+ * @param {object[]} rows The rows.
1488
+ * @returns {string[]}
1489
+ */
1490
+ static getUniqueKeys(rows: object[]): string[];
1491
+ /**
1492
+ * Mark transaction as started from the runner.
1493
+ */
1494
+ useInRunner(): void;
1495
+ /**
1496
+ * Use optimistic concurrency control for the transaction.
1497
+ *
1498
+ * In this concurrency mode, operations during the execution phase, i.e.,
1499
+ * reads and queries, are performed without acquiring locks, and transactional
1500
+ * consistency is ensured by running a validation process in the commit phase
1501
+ * (when any needed locks are acquired). The validation process succeeds only
1502
+ * if there are no conflicting committed transactions (that committed
1503
+ * mutations to the read data at a commit timestamp after the read timestamp).
1504
+ */
1505
+ useOptimisticLock(): void;
1506
+ /**
1507
+ * Use option excludeTxnFromChangeStreams to exclude read/write transactions
1508
+ * from being tracked in change streams.
1509
+ *
1510
+ * Enabling this options to true will effectively disable change stream tracking
1511
+ * for a specified transaction, allowing read/write transaction to operate without being
1512
+ * included in change streams.
1513
+ */
1514
+ excludeTxnFromChangeStreams(): void;
1515
+ }
1516
+ /**
1517
+ * MutationSet represent a set of changes to be applied atomically to a Cloud Spanner
1518
+ * database with a {@link Transaction}.
1519
+ * Mutations are used to insert, update, upsert(insert or update), replace, or
1520
+ * delete rows within tables.
1521
+ *
1522
+ * Mutations are added to a {@link Transaction} and are not executed until the
1523
+ * transaction is committed via {@link Transaction#commit}.
1524
+ *
1525
+ * If the transaction is rolled back or encounters an error, the mutations are
1526
+ * discarded.
1527
+ *
1528
+ * @example
1529
+ * ```
1530
+ * const {Spanner, Mutation} = require('@google-cloud/spanner');
1531
+ * const spanner = new Spanner();
1532
+ *
1533
+ * const instance = spanner.instance('my-instance');
1534
+ * const database = instance.database('my-database');
1535
+ *
1536
+ * const mutations = new MutationSet();
1537
+ * mutations.insert('Singers', {SingerId: '123', FirstName: 'David'});
1538
+ * mutations.update('Singers', {SingerId: '123', FirstName: 'Marc'});
1539
+ *
1540
+ * try {
1541
+ * database.writeAtLeastOnce(mutations, (err, res) => {
1542
+ * console.log("RESPONSE: ", res);
1543
+ * });
1544
+ * } catch(err) {
1545
+ * console.log("ERROR: ", err);
1546
+ * }
1547
+ * ```
1548
+ */
1549
+ export declare class MutationSet {
1550
+ /**
1551
+ * An array to store the mutations.
1552
+ */
1553
+ private _queuedMutations;
1554
+ /**
1555
+ * Creates a new Mutation object.
1556
+ */
1557
+ constructor();
1558
+ /**
1559
+ * Adds an insert operation to the mutation set.
1560
+ * @param {string} table. The name of the table to insert into.
1561
+ * @param {object|object[]} rows. A single row object or an array of row objects to insert.
1562
+ */
1563
+ insert(table: string, rows: object | object[]): void;
1564
+ /**
1565
+ * Adds an update operation to the mutation set.
1566
+ * @param {string} table. The name of the table to update.
1567
+ * @param {object|object[]} rows. A single row object or an array of row objects to update.
1568
+ * Each row object must contain the primary key values to indentify the row to update.
1569
+ */
1570
+ update(table: string, rows: object | object[]): void;
1571
+ /**
1572
+ * Adds an upsert operation to the mutation set.
1573
+ * An upsert will insert a new row if it does not exist or update an existing row if it does.
1574
+ * @param {string} table. The name of the table to upsert.
1575
+ * @param {object|object[]} rows. A single row object or an array of row objects to upsert.
1576
+ */
1577
+ upsert(table: string, rows: object | object[]): void;
1578
+ /**
1579
+ * Adds a replace operation to the mutation set.
1580
+ * A replace operation deletes the existing row (if it exists) and inserts the new row.
1581
+ * @param {string} table. The name of the table to replace.
1582
+ * @param {object|object[]} rows. A single row object or an array of row objects to replace.
1583
+ */
1584
+ replace(table: string, rows: object | object[]): void;
1585
+ /**
1586
+ * Adds a deleteRows operation to the mutation set.
1587
+ * This operation deletes rows from the specified table based on their primary keys.
1588
+ * @param {string} table. The name of the table to deleteRows from.
1589
+ * @param {key[]} key. An array of key objects, each represeting the primary key of a row to delete.
1590
+ */
1591
+ deleteRows(table: string, keys: Key[]): void;
1592
+ /**
1593
+ * Returns the internal representation of the queued mutations as a protobuf message.
1594
+ * @returns {spannerClient.spanner.v1.Mutation[]}. The protobuf message representing the mutations.
1595
+ */
1596
+ proto(): spannerClient.spanner.v1.Mutation[];
1597
+ }
1598
+ /**
1599
+ * A group of mutations to be committed together.
1600
+ * Related mutations should be placed in a group.
1601
+ *
1602
+ * For example, two mutations inserting rows with the same primary
1603
+ * key prefix in both parent and child tables are related.
1604
+ *
1605
+ * This object is created and returned from {@link Database#MutationGroup}.
1606
+ *
1607
+ * @example
1608
+ * ```
1609
+ * const {Spanner} = require('@google-cloud/spanner');
1610
+ * const spanner = new Spanner();
1611
+ *
1612
+ * const instance = spanner.instance('my-instance');
1613
+ * const database = instance.database('my-database');
1614
+ *
1615
+ * const mutationGroup = new MutationGroup();
1616
+ * mutationGroup.insert('Singers', {SingerId: '123', FirstName: 'David'});
1617
+ * mutationGroup.update('Singers', {SingerId: '123', FirstName: 'Marc'});
1618
+ *
1619
+ * database.batchWriteAtLeastOnce([mutationGroup], {})
1620
+ * .on('error', console.error)
1621
+ * .on('data', response => {
1622
+ * console.log('response: ', response);
1623
+ * })
1624
+ * .on('end', () => {
1625
+ * console.log('Request completed successfully');
1626
+ * });
1627
+ * ```
1628
+ */
1629
+ export declare class MutationGroup {
1630
+ private _proto;
1631
+ constructor();
1632
+ insert(table: string, rows: object | object[]): void;
1633
+ update(table: string, rows: object | object[]): void;
1634
+ upsert(table: string, rows: object | object[]): void;
1635
+ replace(table: string, rows: object | object[]): void;
1636
+ deleteRows(table: string, keys: Key[]): void;
1637
+ proto(): spannerClient.spanner.v1.BatchWriteRequest.IMutationGroup;
1638
+ }
1639
+ /**
1640
+ * This type of transaction is used to execute a single Partitioned DML
1641
+ * statement. Partitioned DML partitions the key space and runs the DML
1642
+ * statement over each partition in parallel using separate, internal
1643
+ * transactions that commit independently.
1644
+ *
1645
+ * Chances are, you'll never need to create a partitioned DML transaction
1646
+ * directly, instead you'll want to use {@link Database#runPartitionedUpdate}.
1647
+ *
1648
+ * @class
1649
+ * @extends Snapshot
1650
+ *
1651
+ * @see Database#runPartitionedUpdate
1652
+ */
1653
+ export declare class PartitionedDml extends Dml {
1654
+ constructor(session: Session, options?: spannerClient.spanner.v1.TransactionOptions.PartitionedDml);
1655
+ /**
1656
+ * Use option excludeTxnFromChangeStreams to exclude partitionedDml
1657
+ * queries from being tracked in change streams.
1658
+ *
1659
+ * Enabling this options to true will effectively disable change stream tracking
1660
+ * for a specified partitionedDml query, allowing write queries to operate
1661
+ * without being included in change streams.
1662
+ */
1663
+ excludeTxnFromChangeStreams(): void;
1664
+ /**
1665
+ * Execute a DML statement and get the affected row count. Unlike
1666
+ * {@link Transaction#runUpdate} after using this method you should
1667
+ * immediately discard this transaction, internally it will invoke
1668
+ * {@link PartitionedDml#end}.
1669
+ *
1670
+ * @see Database#runPartitionedUpdate
1671
+ *
1672
+ * @param {string|object} query A DML statement or
1673
+ * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
1674
+ * object.
1675
+ * @param {object} [query.params] A map of parameter name to values.
1676
+ * @param {object} [query.types] A map of parameter types.
1677
+ * @param {RunUpdateCallback} [callback] Callback function.
1678
+ * @returns {Promise<RunUpdateResponse>}
1679
+ *
1680
+ * @example
1681
+ * ```
1682
+ * transaction.runUpdate(query, (err, rowRount) => {
1683
+ * if (err) {
1684
+ * // Error handling omitted.
1685
+ * }
1686
+ * });
1687
+ * ```
1688
+ */
1689
+ runUpdate(query: string | ExecuteSqlRequest): Promise<RunUpdateResponse>;
1690
+ runUpdate(query: string | ExecuteSqlRequest, callback: RunUpdateCallback): void;
1691
+ }