@google-cloud/spanner 5.15.1 → 5.16.2

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.
@@ -61,6 +61,7 @@ const RETRY_INFO_BIN = 'google.rpc.retryinfo-bin';
61
61
  * @see [Timestamp Bounds API Documentation](https://cloud.google.com/spanner/docs/timestamp-bounds)
62
62
  *
63
63
  * @example
64
+ * ```
64
65
  * const {Spanner} = require('@google-cloud/spanner');
65
66
  * const spanner = new Spanner();
66
67
  *
@@ -79,6 +80,7 @@ const RETRY_INFO_BIN = 'google.rpc.retryinfo-bin';
79
80
  * // It should be called when the snapshot finishes.
80
81
  * transaction.end();
81
82
  * });
83
+ * ```
82
84
  */
83
85
  class Snapshot extends events_1.EventEmitter {
84
86
  /**
@@ -138,47 +140,6 @@ class Snapshot extends events_1.EventEmitter {
138
140
  [common_1.CLOUD_RESOURCE_HEADER]: this.session.parent.formattedName_,
139
141
  };
140
142
  }
141
- /**
142
- * @typedef {object} TransactionResponse
143
- * @property {string|Buffer} id The transaction ID.
144
- * @property {?google.protobuf.Timestamp} readTimestamp For snapshot read-only
145
- * transactions, the read timestamp chosen for the transaction.
146
- */
147
- /**
148
- * @typedef {array} TransactionBeginResponse
149
- * @property {TransactionResponse} 0 The raw transaction object.
150
- */
151
- /**
152
- * @callback TransactionBeginCallback
153
- * @param {?Error} err Request error, if any.
154
- * @param {TransactionResponse} apiResponse The raw transaction object.
155
- */
156
- /**
157
- * Begin a new transaction. Typically, you need not call this unless
158
- * manually creating transactions via {@link Session} objects.
159
- *
160
- * @see [BeginTransaction API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.BeginTransaction)
161
- *
162
- * @param {object} [gaxOptions] Request configuration options,
163
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
164
- * for more details.
165
- * @param {TransactionBeginCallback} [callback] Callback function.
166
- * @returns {Promise<TransactionBeginResponse>}
167
- *
168
- * @example
169
- * transaction.begin(function(err) {
170
- * if (!err) {
171
- * // transaction began successfully.
172
- * }
173
- * });
174
- *
175
- * @example <caption>If the callback is omitted, the function returns a Promise
176
- * </caption>
177
- * transaction.begin()
178
- * .then(function(data) {
179
- * const apiResponse = data[0];
180
- * });
181
- */
182
143
  begin(gaxOptionsOrCallback, cb) {
183
144
  const gaxOpts = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {};
184
145
  const callback = typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb;
@@ -291,6 +252,7 @@ class Snapshot extends events_1.EventEmitter {
291
252
  * @returns {ReadableStream} A readable stream that emits rows.
292
253
  *
293
254
  * @example
255
+ * ```
294
256
  * transaction.createReadStream('Singers', {
295
257
  * keys: ['1'],
296
258
  * columns: ['SingerId', 'name']
@@ -312,8 +274,10 @@ class Snapshot extends events_1.EventEmitter {
312
274
  * // All results retrieved.
313
275
  * });
314
276
  *
315
- * @example <caption>Provide an array for `query.keys` to read with a
316
- * composite key.</caption>
277
+ * ```
278
+ * @example Provide an array for `query.keys` to read with a
279
+ * composite key.
280
+ * ```
317
281
  * const query = {
318
282
  * keys: [
319
283
  * [
@@ -327,10 +291,12 @@ class Snapshot extends events_1.EventEmitter {
327
291
  * ],
328
292
  * // ...
329
293
  * };
294
+ * ```
330
295
  *
331
- * @example <caption>Rows are returned as an array of object arrays. Each
296
+ * @example Rows are returned as an array of object arrays. Each
332
297
  * object has a `name` and `value` property. To get a serialized object, call
333
- * `toJSON()`.</caption>
298
+ * `toJSON()`.
299
+ * ```
334
300
  * transaction.createReadStream('Singers', {
335
301
  * keys: ['1'],
336
302
  * columns: ['SingerId', 'name']
@@ -345,9 +311,11 @@ class Snapshot extends events_1.EventEmitter {
345
311
  * .on('end', function() {
346
312
  * // All results retrieved.
347
313
  * });
314
+ * ```
348
315
  *
349
- * @example <caption>Alternatively, set `query.json` to `true`, and this step
350
- * will perform automatically.</caption>
316
+ * @example Alternatively, set `query.json` to `true`, and this step
317
+ * will perform automatically.
318
+ * ```
351
319
  * transaction.createReadStream('Singers', {
352
320
  * keys: ['1'],
353
321
  * columns: ['SingerId', 'name'],
@@ -363,9 +331,11 @@ class Snapshot extends events_1.EventEmitter {
363
331
  * .on('end', function() {
364
332
  * // All results retrieved.
365
333
  * });
334
+ * ```
366
335
  *
367
- * @example <caption>If you anticipate many results, you can end a stream
368
- * early to prevent unnecessary processing and API requests.</caption>
336
+ * @example If you anticipate many results, you can end a stream
337
+ * early to prevent unnecessary processing and API requests.
338
+ * ```
369
339
  * transaction.createReadStream('Singers', {
370
340
  * keys: ['1'],
371
341
  * columns: ['SingerId', 'name']
@@ -373,6 +343,7 @@ class Snapshot extends events_1.EventEmitter {
373
343
  * .on('data', function(row) {
374
344
  * this.end();
375
345
  * });
346
+ * ```
376
347
  */
377
348
  createReadStream(table, request = {}) {
378
349
  var _a;
@@ -420,7 +391,8 @@ class Snapshot extends events_1.EventEmitter {
420
391
  * mainly be called for {@link Snapshot} objects, however in certain cases
421
392
  * you may want to call them for {@link Transaction} objects as well.
422
393
  *
423
- * @example <caption>Calling `end` on a read only snapshot</caption>
394
+ * @example Calling `end` on a read only snapshot
395
+ * ```
424
396
  * database.getSnapshot((err, transaction) => {
425
397
  * if (err) {
426
398
  * // Error handling omitted.
@@ -435,8 +407,10 @@ class Snapshot extends events_1.EventEmitter {
435
407
  * transaction.end();
436
408
  * });
437
409
  * });
410
+ * ```
438
411
  *
439
- * @example <caption>Calling `end` on a read/write transaction</caption>
412
+ * @example Calling `end` on a read/write transaction
413
+ * ```
440
414
  * database.runTransaction((err, transaction) => {
441
415
  * if (err) {
442
416
  * // Error handling omitted.
@@ -455,6 +429,7 @@ class Snapshot extends events_1.EventEmitter {
455
429
  * transaction.commit(err => {});
456
430
  * });
457
431
  * });
432
+ * ```
458
433
  */
459
434
  end() {
460
435
  if (this.ended) {
@@ -463,115 +438,6 @@ class Snapshot extends events_1.EventEmitter {
463
438
  this.ended = true;
464
439
  process.nextTick(() => this.emit('end'));
465
440
  }
466
- /**
467
- * @typedef {array} ReadResponse
468
- * @property {array[]} 0 Rows are returned as an array of object arrays. Each
469
- * object has a `name` and `value` property. To get a serialized object,
470
- * call `toJSON()`. Optionally, provide an options object to `toJSON()`
471
- * specifying `wrapNumbers: true` to protect large integer values outside
472
- * of the range of JavaScript Number. If set, FLOAT64 values are returned
473
- * as {@link Spanner.Float} objects and INT64 values as {@link
474
- * Spanner.Int}.
475
- */
476
- /**
477
- * @callback ReadCallback
478
- * @param {?Error} err Request error, if any.
479
- * @param {array[]} rows Rows are returned as an array of object arrays. Each
480
- * object has a `name` and `value` property. To get a serialized object,
481
- * call `toJSON()`. Optionally, provide an options object to `toJSON()`
482
- * specifying `wrapNumbers: true` to protect large integer values outside
483
- * of the range of JavaScript Number. If set, FLOAT64 values are returned
484
- * as {@link Spanner.Float} objects and INT64 values as {@link
485
- * Spanner.Int}.
486
- */
487
- /**
488
- * Performs a read request against the specified Table.
489
- *
490
- * Wrapper around {@link v1.SpannerClient#read}.
491
- *
492
- * @see {@link v1.SpannerClient#read}
493
- *
494
- * @param {string} table The table to read from.
495
- * @param {ReadRequest} query Configuration object. See official
496
- * [`ReadRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ReadRequest).
497
- * API documentation.
498
- * @param {ReadCallback} [callback] Callback function.
499
- * @returns {Promise<ReadResponse>}
500
- *
501
- * @example
502
- * const query = {
503
- * keys: ['1'],
504
- * columns: ['SingerId', 'name']
505
- * };
506
- *
507
- * transaction.read('Singers', query, function(err, rows) {
508
- * if (err) {
509
- * // Error handling omitted.
510
- * }
511
- *
512
- * const firstRow = rows[0];
513
- *
514
- * // firstRow = [
515
- * // {
516
- * // name: 'SingerId',
517
- * // value: '1'
518
- * // },
519
- * // {
520
- * // name: 'Name',
521
- * // value: 'Eddie Wilson'
522
- * // }
523
- * // ]
524
- * });
525
- *
526
- * @example <caption>Provide an array for `query.keys` to read with a
527
- * composite key.</caption>
528
- * const query = {
529
- * keys: [
530
- * [
531
- * 'Id1',
532
- * 'Name1'
533
- * ],
534
- * [
535
- * 'Id2',
536
- * 'Name2'
537
- * ]
538
- * ],
539
- * // ...
540
- * };
541
- *
542
- * @example <caption>Rows are returned as an array of object arrays. Each
543
- * object has a `name` and `value` property. To get a serialized object, call
544
- * `toJSON()`.</caption>
545
- * transaction.read('Singers', query, function(err, rows) {
546
- * if (err) {
547
- * // Error handling omitted.
548
- * }
549
- *
550
- * const firstRow = rows[0];
551
- *
552
- * // firstRow.toJSON() = {
553
- * // SingerId: '1',
554
- * // Name: 'Eddie Wilson'
555
- * // }
556
- * });
557
- *
558
- * @example <caption>Alternatively, set `query.json` to `true`, and this step
559
- * will perform automatically.</caption>
560
- * query.json = true;
561
- *
562
- * transaction.read('Singers', query, function(err, rows) {
563
- * if (err) {
564
- * // Error handling omitted.
565
- * }
566
- *
567
- * const firstRow = rows[0];
568
- *
569
- * // firstRow = {
570
- * // SingerId: '1',
571
- * // Name: 'Eddie Wilson'
572
- * // }
573
- * });
574
- */
575
441
  read(table, requestOrCallback, cb) {
576
442
  const rows = [];
577
443
  let request;
@@ -589,79 +455,6 @@ class Snapshot extends events_1.EventEmitter {
589
455
  .on('data', row => rows.push(row))
590
456
  .on('end', () => callback(null, rows));
591
457
  }
592
- /**
593
- * Execute a SQL statement on this database inside of a transaction.
594
- *
595
- * **Performance Considerations:**
596
- *
597
- * This method wraps the streaming method,
598
- * {@link Snapshot#run} for your convenience. All rows are stored in memory
599
- * before releasing to your callback. If you intend to receive a lot of
600
- * results from your query, consider using the streaming method,
601
- * so you can free each result from memory after consuming it.
602
- *
603
- * Wrapper around {@link v1.SpannerClient#executeStreamingSql}.
604
- *
605
- * @see {@link v1.SpannerClient#executeStreamingSql}
606
- * @see [ExecuteStreamingSql API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ExecuteStreamingSql)
607
- * @see [ExecuteSqlRequest API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
608
- *
609
- * @param {string|ExecuteSqlRequest} query A SQL query or
610
- * {@link ExecuteSqlRequest} object.
611
- * @param {RunCallback} [callback] Callback function.
612
- * @returns {Promise<RunResponse>}
613
- *
614
- * @example
615
- * transaction.run(query, function(err, rows) {
616
- * if (err) {
617
- * // Error handling omitted.
618
- * }
619
- *
620
- * // rows = [
621
- * // {
622
- * // SingerId: '1',
623
- * // Name: 'Eddie Wilson'
624
- * // }
625
- * // ]
626
- * });
627
- *
628
- * @example <caption>The SQL query string can contain parameter placeholders.
629
- * A parameter placeholder consists of '@' followed by the parameter name.
630
- * </caption>
631
- * const query = {
632
- * sql: 'SELECT * FROM Singers WHERE name = @name',
633
- * params: {
634
- * name: 'Eddie Wilson'
635
- * }
636
- * };
637
- *
638
- * transaction.run(query, function(err, rows) {
639
- * if (err) {
640
- * // Error handling omitted.
641
- * }
642
- * });
643
- *
644
- * @example <caption>If you need to enforce a specific param type, a types map
645
- * can be provided. This is typically useful if your param value can be null.
646
- * </caption>
647
- * const query = {
648
- * sql: 'SELECT * FROM Singers WHERE name = @name AND id = @id',
649
- * params: {
650
- * id: spanner.int(8),
651
- * name: null
652
- * },
653
- * types: {
654
- * id: 'int64',
655
- * name: 'string'
656
- * }
657
- * };
658
- *
659
- * transaction.run(query, function(err, rows) {
660
- * if (err) {
661
- * // Error handling omitted.
662
- * }
663
- * });
664
- */
665
458
  run(query, callback) {
666
459
  const rows = [];
667
460
  let stats;
@@ -733,6 +526,7 @@ class Snapshot extends events_1.EventEmitter {
733
526
  * @returns {ReadableStream}
734
527
  *
735
528
  * @example
529
+ * ```
736
530
  * const query = 'SELECT * FROM Singers';
737
531
  *
738
532
  * transaction.runStream(query)
@@ -747,9 +541,10 @@ class Snapshot extends events_1.EventEmitter {
747
541
  * // All results retrieved.
748
542
  * });
749
543
  *
750
- * @example <caption>The SQL query string can contain parameter placeholders.
544
+ * ```
545
+ * @example The SQL query string can contain parameter placeholders.
751
546
  * A parameter placeholder consists of '@' followed by the parameter name.
752
- * </caption>
547
+ * ```
753
548
  * const query = {
754
549
  * sql: 'SELECT * FROM Singers WHERE name = @name',
755
550
  * params: {
@@ -761,13 +556,16 @@ class Snapshot extends events_1.EventEmitter {
761
556
  * .on('error', function(err) {})
762
557
  * .on('data', function(row) {})
763
558
  * .on('end', function() {});
559
+ * ```
764
560
  *
765
- * @example <caption>If you anticipate many results, you can end a stream
766
- * early to prevent unnecessary processing and API requests.</caption>
561
+ * @example If you anticipate many results, you can end a stream
562
+ * early to prevent unnecessary processing and API requests.
563
+ * ```
767
564
  * transaction.runStream(query)
768
565
  * .on('data', function(row) {
769
566
  * this.end();
770
567
  * });
568
+ * ```
771
569
  */
772
570
  runStream(query) {
773
571
  if (typeof query === 'string') {
@@ -948,30 +746,6 @@ promisify_1.promisifyAll(Snapshot, {
948
746
  * @class
949
747
  */
950
748
  class Dml extends Snapshot {
951
- /**
952
- * @typedef {array} RunUpdateResponse
953
- * @property {number} 0 Affected row count.
954
- */
955
- /**
956
- * @callback RunUpdateCallback
957
- * @param {?Error} err Request error, if any.
958
- * @param {number} rowCount Affected row count.
959
- */
960
- /**
961
- * Execute a DML statement and get the affected row count.
962
- *
963
- * @private
964
- *
965
- * @see {@link Transaction#run}
966
- *
967
- * @param {string|object} query A DML statement or
968
- * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
969
- * object.
970
- * @param {object} [query.params] A map of parameter name to values.
971
- * @param {object} [query.types] A map of parameter types.
972
- * @param {RunUpdateCallback} [callback] Callback function.
973
- * @returns {Promise<RunUpdateResponse>}
974
- */
975
749
  runUpdate(query, callback) {
976
750
  if (typeof query === 'string') {
977
751
  query = { sql: query };
@@ -1017,6 +791,7 @@ promisify_1.promisifyAll(Dml);
1017
791
  * @param {Session} session The parent Session object.
1018
792
  *
1019
793
  * @example
794
+ * ```
1020
795
  * const {Spanner} = require('@google-cloud/spanner');
1021
796
  * const spanner = new Spanner();
1022
797
  *
@@ -1027,11 +802,14 @@ promisify_1.promisifyAll(Dml);
1027
802
  * // The `transaction` object is ready for use.
1028
803
  * });
1029
804
  *
1030
- * @example <caption>To manually control retrying the transaction, use the
1031
- * `getTransaction` method.</caption>
805
+ * ```
806
+ * @example To manually control retrying the transaction, use the
807
+ * `getTransaction` method.
808
+ * ```
1032
809
  * database.getTransaction(function(err, transaction) {
1033
810
  * // The `transaction` object is ready for use.
1034
811
  * });
812
+ * ```
1035
813
  */
1036
814
  class Transaction extends Dml {
1037
815
  /**
@@ -1064,6 +842,7 @@ class Transaction extends Dml {
1064
842
  * @returns {Promise<RunUpdateResponse>}
1065
843
  *
1066
844
  * @example
845
+ * ```
1067
846
  * const query = 'UPDATE Account SET Balance = 1000 WHERE Key = 1';
1068
847
  *
1069
848
  * transaction.runUpdate(query, (err, rowCount) => {
@@ -1071,6 +850,7 @@ class Transaction extends Dml {
1071
850
  * // Error handling omitted.
1072
851
  * }
1073
852
  * });
853
+ * ```
1074
854
  */
1075
855
  constructor(session, options = {}, queryOptions, requestOptions) {
1076
856
  super(session, undefined, queryOptions);
@@ -1078,71 +858,6 @@ class Transaction extends Dml {
1078
858
  this._options = { readWrite: options };
1079
859
  this.requestOptions = requestOptions;
1080
860
  }
1081
- /**
1082
- * @typedef {error} BatchUpdateError
1083
- * @property {number} code gRPC status code.
1084
- * @property {?object} metadata gRPC metadata.
1085
- * @property {number[]} rowCounts The affected row counts for any DML
1086
- * statements that were executed successfully before this error occurred.
1087
- */
1088
- /**
1089
- * @typedef {object} BatchUpdateOptions
1090
- * @property {object} [gaxOptions] Request configuration options,
1091
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1092
- * for more details.
1093
- * @property {google.spanner.v1.IRequestOptions} [requestOptions] The request options to include
1094
- * with the commit request.
1095
- */
1096
- /**
1097
- * @typedef {array} BatchUpdateResponse
1098
- * @property {number[]} 0 Affected row counts.
1099
- * @property {object} 1 The full API response.
1100
- */
1101
- /**
1102
- * @callback BatchUpdateCallback
1103
- * @param {?BatchUpdateError} err Request error, if any.
1104
- * @param {number[]} rowCounts Affected row counts.
1105
- * @param {object} apiResponse The full API response.
1106
- */
1107
- /**
1108
- * Execute a series of DML statements and get the affected row counts.
1109
- *
1110
- * If any of the DML statements fail, the returned error will contain a list
1111
- * of results for all successfully executed statements.
1112
- *
1113
- * @param {string[]|object[]} query A DML statement or
1114
- * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
1115
- * object.
1116
- * @param {object} [query.params] A map of parameter name to values.
1117
- * @param {object} [query.types] A map of parameter types.
1118
- * @param {object} [gaxOptions] Request configuration options,
1119
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1120
- * for more details.
1121
- * @param {BatchUpdateOptions} [options] Options for configuring the request.
1122
- * @param {RunUpdateCallback} [callback] Callback function.
1123
- * @returns {Promise<RunUpdateResponse>}
1124
- *
1125
- * @example
1126
- * const queries = [
1127
- * {
1128
- * sql: 'INSERT INTO MyTable (Key, Value) VALUES (@key, @value)',
1129
- * params: {key: 'my-key', value: 'my-value'},
1130
- * },
1131
- * {
1132
- * sql: 'UPDATE MyTable t SET t.Value = @value WHERE t.KEY = @key',
1133
- * params: {key: 'my-other-key', value: 'my-other-value'}
1134
- * }
1135
- * ];
1136
- *
1137
- * transaction.batchUpdate(queries, (err, rowCounts, apiResponse) => {
1138
- * if (err) {
1139
- * // Error handling omitted.
1140
- * }
1141
- * });
1142
- *
1143
- * @example <caption>If the callback is omitted, we'll return a Promise.</caption>
1144
- * const [rowCounts, apiResponse] = await transaction.batchUpdate(queries);
1145
- */
1146
861
  batchUpdate(queries, optionsOrCallback, cb) {
1147
862
  var _a;
1148
863
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
@@ -1218,66 +933,6 @@ class Transaction extends Dml {
1218
933
  }
1219
934
  return undefined;
1220
935
  }
1221
- /**
1222
- * @typedef {object} CommitOptions
1223
- * @property {google.spanner.v1.IRequestOptions} requestOptions The request options to include
1224
- * with the commit request.
1225
- * @property {boolean} returnCommitStats Include statistics related to the
1226
- * transaction in the {@link CommitResponse}.
1227
- * @property {object} [gaxOptions] The request configuration options,
1228
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1229
- * for more details.
1230
- */
1231
- /**
1232
- * @typedef {object} CommitResponse
1233
- * @property {google.protobuf.Timestamp} commitTimestamp The transaction
1234
- * commit timestamp.
1235
- * @property {google.spanner.v1.CommitResponse.ICommitStats|null} commitStats
1236
- * The statistics about this commit. Only populated if requested in
1237
- * {@link CommitOptions}.
1238
- */
1239
- /**
1240
- * @typedef {array} CommitPromiseResponse
1241
- * @property {CommitResponse} 0 The commit response.
1242
- */
1243
- /**
1244
- * @callback CommitCallback
1245
- * @param {?Error} error Request error, if any.
1246
- * @param {CommitResponse} apiResponse The full API response.
1247
- */
1248
- /**
1249
- * Commit the transaction.
1250
- *
1251
- * Wrapper around {@link v1.SpannerClient#commit}.
1252
- *
1253
- * @see {@link v1.SpannerClient#commit}
1254
- * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
1255
- *
1256
- * @param {CommitOptions} [options] Options for configuring the request.
1257
- * @param {CommitCallback} [callback] Callback function.
1258
- * @returns {Promise<CommitPromiseResponse>}
1259
- *
1260
- * @example
1261
- * database.runTransaction(function(err, transaction) {
1262
- * if (err) {
1263
- * // Error handling omitted.
1264
- * }
1265
- *
1266
- * // Queue a mutation (note that there is no callback passed to `insert`).
1267
- * transaction.insert('Singers', {
1268
- * SingerId: 'Id3b',
1269
- * Name: 'Joe West'
1270
- * });
1271
- *
1272
- * // Commit the transaction.
1273
- * transaction.commit(function(err, apiResponse) {
1274
- * if (!err) {
1275
- * // Get the commit timestamp on successful commits.
1276
- * const {commitTimestamp} = apiResponse;
1277
- * }
1278
- * });
1279
- * });
1280
- */
1281
936
  commit(optionsOrCallback, cb) {
1282
937
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
1283
938
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -1394,6 +1049,7 @@ class Transaction extends Dml {
1394
1049
  * below.
1395
1050
  *
1396
1051
  * @example
1052
+ * ```
1397
1053
  * const keys = ['Id1', 'Id2', 'Id3'];
1398
1054
  *
1399
1055
  * database.runTransaction(function(err, transaction) {
@@ -1413,8 +1069,10 @@ class Transaction extends Dml {
1413
1069
  * });
1414
1070
  * });
1415
1071
  *
1416
- * @example <caption>Provide an array for `keys` to delete rows with a
1417
- * composite key.</caption>
1072
+ * ```
1073
+ * @example Provide an array for `keys` to delete rows with a
1074
+ * composite key.
1075
+ * ```
1418
1076
  * const keys = [
1419
1077
  * [
1420
1078
  * 'Id1',
@@ -1425,6 +1083,7 @@ class Transaction extends Dml {
1425
1083
  * 'Name2'
1426
1084
  * ]
1427
1085
  * ];
1086
+ * ```
1428
1087
  */
1429
1088
  deleteRows(table, keys) {
1430
1089
  const keySet = {
@@ -1445,6 +1104,7 @@ class Transaction extends Dml {
1445
1104
  * into this table.
1446
1105
  *
1447
1106
  * @example
1107
+ * ```
1448
1108
  * const row = {
1449
1109
  * SingerId: 'Id3',
1450
1110
  * Name: 'Eddie Wilson'
@@ -1467,7 +1127,9 @@ class Transaction extends Dml {
1467
1127
  * });
1468
1128
  * });
1469
1129
  *
1470
- * @example <caption>Multiple rows can be inserted at once.</caption>
1130
+ * ```
1131
+ * @example Multiple rows can be inserted at once.
1132
+ * ```
1471
1133
  * const row2 = {
1472
1134
  * SingerId: 'Id3b',
1473
1135
  * Name: 'Joe West'
@@ -1492,6 +1154,7 @@ class Transaction extends Dml {
1492
1154
  * }
1493
1155
  * });
1494
1156
  * });
1157
+ * ```
1495
1158
  */
1496
1159
  insert(table, rows) {
1497
1160
  this._mutate('insert', table, rows);
@@ -1506,6 +1169,7 @@ class Transaction extends Dml {
1506
1169
  * into this table.
1507
1170
  *
1508
1171
  * @example
1172
+ * ```
1509
1173
  * const row = {
1510
1174
  * SingerId: 'Id3',
1511
1175
  * Name: 'Joe West'
@@ -1527,39 +1191,11 @@ class Transaction extends Dml {
1527
1191
  * }
1528
1192
  * });
1529
1193
  * });
1194
+ * ```
1530
1195
  */
1531
1196
  replace(table, rows) {
1532
1197
  this._mutate('replace', table, rows);
1533
1198
  }
1534
- /**
1535
- * Roll back a transaction, releasing any locks it holds. It is a good idea to
1536
- * call this for any transaction that includes one or more queries that you
1537
- * decide not to commit.
1538
- *
1539
- * Wrapper around {@link v1.SpannerClient#rollback}.
1540
- *
1541
- * @see {@link v1.SpannerClient#rollback}
1542
- * @see [Rollback API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Rollback)
1543
- *
1544
- * @param {object} [gaxOptions] Request configuration options,
1545
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1546
- * for more details.
1547
- * @param {BasicCallback} [callback] Callback function.
1548
- * @returns {Promise<BasicResponse>}
1549
- *
1550
- * @example
1551
- * database.runTransaction(function(err, transaction) {
1552
- * if (err) {
1553
- * // Error handling omitted.
1554
- * }
1555
- *
1556
- * transaction.rollback(function(err) {
1557
- * if (!err) {
1558
- * // Transaction rolled back successfully.
1559
- * }
1560
- * });
1561
- * });
1562
- */
1563
1199
  rollback(gaxOptionsOrCallback, cb) {
1564
1200
  const gaxOpts = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {};
1565
1201
  const callback = typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb;
@@ -1594,6 +1230,7 @@ class Transaction extends Dml {
1594
1230
  * into this table.
1595
1231
  *
1596
1232
  * @example
1233
+ * ```
1597
1234
  * const row = {
1598
1235
  * SingerId: 'Id3',
1599
1236
  * Name: 'Joe West'
@@ -1615,6 +1252,7 @@ class Transaction extends Dml {
1615
1252
  * }
1616
1253
  * });
1617
1254
  * });
1255
+ * ```
1618
1256
  */
1619
1257
  update(table, rows) {
1620
1258
  this._mutate('update', table, rows);
@@ -1629,6 +1267,7 @@ class Transaction extends Dml {
1629
1267
  * into this table.
1630
1268
  *
1631
1269
  * @example
1270
+ * ```
1632
1271
  * const row = {
1633
1272
  * SingerId: 'Id3',
1634
1273
  * Name: 'Joe West'
@@ -1650,6 +1289,7 @@ class Transaction extends Dml {
1650
1289
  * }
1651
1290
  * });
1652
1291
  * });
1292
+ * ```
1653
1293
  */
1654
1294
  upsert(table, rows) {
1655
1295
  this._mutate('insertOrUpdate', table, rows);
@@ -1728,29 +1368,6 @@ class PartitionedDml extends Dml {
1728
1368
  super(session);
1729
1369
  this._options = { partitionedDml: options };
1730
1370
  }
1731
- /**
1732
- * Execute a DML statement and get the affected row count. Unlike
1733
- * {@link Transaction#runUpdate} after using this method you should
1734
- * immediately discard this transaction, internally it will invoke
1735
- * {@link PartitionedDml#end}.
1736
- *
1737
- * @see Database#runPartitionedUpdate
1738
- *
1739
- * @param {string|object} query A DML statement or
1740
- * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
1741
- * object.
1742
- * @param {object} [query.params] A map of parameter name to values.
1743
- * @param {object} [query.types] A map of parameter types.
1744
- * @param {RunUpdateCallback} [callback] Callback function.
1745
- * @returns {Promise<RunUpdateResponse>}
1746
- *
1747
- * @example
1748
- * transaction.runUpdate(query, (err, rowRount) => {
1749
- * if (err) {
1750
- * // Error handling omitted.
1751
- * }
1752
- * });
1753
- */
1754
1371
  runUpdate(query, callback) {
1755
1372
  super.runUpdate(query, (err, count) => {
1756
1373
  this.end();