@google-cloud/spanner 5.15.0 → 5.16.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.
@@ -28,12 +28,14 @@ const through = require("through2");
28
28
  * @param {string} name Name of the table.
29
29
  *
30
30
  * @example
31
+ * ```
31
32
  * const {Spanner} = require('@google-cloud/spanner');
32
33
  * const spanner = new Spanner();
33
34
  *
34
35
  * const instance = spanner.instance('my-instance');
35
36
  * const database = instance.database('my-database');
36
37
  * const table = database.table('my-table');
38
+ * ```
37
39
  */
38
40
  class Table {
39
41
  constructor(database, name) {
@@ -50,58 +52,6 @@ class Table {
50
52
  */
51
53
  this.name = name;
52
54
  }
53
- /**
54
- * Create a table.
55
- *
56
- * @param {string} schema See {@link Database#createTable}.
57
- * @param {object} [gaxOptions]
58
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
59
- * for more details.
60
- * @param {CreateTableCallback} [callback] Callback function.
61
- * @returns {Promise<CreateTableResponse>}
62
- *
63
- * @example
64
- * const {Spanner} = require('@google-cloud/spanner');
65
- * const spanner = new Spanner();
66
- *
67
- * const instance = spanner.instance('my-instance');
68
- * const database = instance.database('my-database');
69
- * const table = database.table('Singers');
70
- *
71
- * const schema =
72
- * 'CREATE TABLE Singers (' +
73
- * ' SingerId INT64 NOT NULL,' +
74
- * ' FirstName STRING(1024),' +
75
- * ' LastName STRING(1024),' +
76
- * ' SingerInfo BYTES(MAX),' +
77
- * ') PRIMARY KEY(SingerId)';
78
- *
79
- * table.create(schema, function(err, table, operation, apiResponse) {
80
- * if (err) {
81
- * // Error handling omitted.
82
- * }
83
- *
84
- * operation
85
- * .on('error', function(err) {})
86
- * .on('complete', function() {
87
- * // Table created successfully.
88
- * });
89
- * });
90
- *
91
- * //-
92
- * // If the callback is omitted, we'll return a Promise.
93
- * //-
94
- * table.create(schema)
95
- * .then(function(data) {
96
- * const table = data[0];
97
- * const operation = data[1];
98
- *
99
- * return operation.promise();
100
- * })
101
- * .then(function() {
102
- * // Table created successfully.
103
- * });
104
- */
105
55
  create(schema, gaxOptionsOrCallback, cb) {
106
56
  const gaxOptions = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {};
107
57
  const callback = typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb;
@@ -119,6 +69,7 @@ class Table {
119
69
  * @returns {PartialResultStream} A readable stream that emits rows.
120
70
  *
121
71
  * @example
72
+ * ```
122
73
  * const {Spanner} = require('@google-cloud/spanner');
123
74
  * const spanner = new Spanner();
124
75
  *
@@ -169,6 +120,7 @@ class Table {
169
120
  * .on('data', function(row) {
170
121
  * this.end();
171
122
  * });
123
+ * ```
172
124
  */
173
125
  createReadStream(request, options = {}) {
174
126
  const proxyStream = through.obj();
@@ -188,409 +140,26 @@ class Table {
188
140
  });
189
141
  return proxyStream;
190
142
  }
191
- /**
192
- * @typedef {array} DropTableResponse
193
- * @property {google.longrunning.Operation} 0 An {@link Operation} object that can be used to check
194
- * the status of the request.
195
- * @property {object} 1 The full API response.
196
- */
197
- /**
198
- * @callback DropTableCallback
199
- * @param {?Error} err Request error, if any.
200
- * @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
201
- * check the status of the request.
202
- * @param {object} apiResponse The full API response.
203
- */
204
- /**
205
- * Delete the table. Not to be confused with {@link Table#deleteRows}.
206
- *
207
- * Wrapper around {@link Database#updateSchema}.
208
- *
209
- * @see {@link Database#updateSchema}
210
- *
211
- * @throws {TypeError} If any arguments are passed in.
212
- * @param {object} [gaxOptions]
213
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
214
- * for more details.
215
- * @param {DropTableCallback} [callback] Callback function.
216
- * @returns {Promise<DropTableResponse>}
217
- *
218
- * @example
219
- * const {Spanner} = require('@google-cloud/spanner');
220
- * const spanner = new Spanner();
221
- *
222
- * const instance = spanner.instance('my-instance');
223
- * const database = instance.database('my-database');
224
- * const table = database.table('Singers');
225
- *
226
- * table.delete(function(err, operation, apiResponse) {
227
- * if (err) {
228
- * // Error handling omitted.
229
- * }
230
- *
231
- * operation
232
- * .on('error', function(err) {})
233
- * .on('complete', function() {
234
- * // Table deleted successfully.
235
- * });
236
- * });
237
- *
238
- * //-
239
- * // If the callback is omitted, we'll return a Promise.
240
- * //-
241
- * table.delete()
242
- * .then(function(data) {
243
- * const operation = data[0];
244
- * return operation.promise();
245
- * })
246
- * .then(function() {
247
- * // Table deleted successfully.
248
- * });
249
- */
250
143
  delete(gaxOptionsOrCallback, cb) {
251
144
  const gaxOptions = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {};
252
145
  const callback = typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb;
253
146
  return this.database.updateSchema('DROP TABLE `' + this.name + '`', gaxOptions, callback);
254
147
  }
255
- /**
256
- * @typedef {array} DeleteRowsResponse
257
- * @property {CommitResponse} 0 The commit response.
258
- */
259
- /**
260
- * @callback DeleteRowsCallback
261
- * @param {?Error} error Request error, if any.
262
- * @param {CommitResponse} apiResponse The full API response.
263
- */
264
- /**
265
- * @typedef {object} DeleteRowsOptions
266
- * @property {google.spanner.v1.IRequestOptions} requestOptions The request options to include
267
- * with the commit request.
268
- * @property {boolean} returnCommitStats Include statistics related to the
269
- * transaction in the {@link CommitResponse}.
270
- * @property {object} [gaxOptions]
271
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
272
- * for more details.
273
- */
274
- /**
275
- * Delete rows from this table.
276
- *
277
- * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
278
- *
279
- * @param {array} keys The keys for the rows to delete. If using a
280
- * composite key, provide an array within this array. See the example
281
- * below.
282
- * @param {DeleteRowsOptions|CallOptions} [options] Options for configuring the request.
283
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
284
- * for more details.
285
- * @param {DeleteRowsCallback} [callback] Callback function.
286
- * @returns {Promise<DeleteRowsResponse>}
287
- *
288
- * @example
289
- * const {Spanner} = require('@google-cloud/spanner');
290
- * const spanner = new Spanner();
291
- *
292
- * const instance = spanner.instance('my-instance');
293
- * const database = instance.database('my-database');
294
- * const table = database.table('Singers');
295
- *
296
- * const keys = ['Id1', 'Id2', 'Id3'];
297
- *
298
- * table.deleteRows(keys, function(err, apiResponse) {});
299
- *
300
- * //-
301
- * // Provide an array for `keys` to delete rows with a composite key.
302
- * //-
303
- * const keys = [
304
- * [
305
- * 'Id1',
306
- * 'Name1'
307
- * ],
308
- * [
309
- * 'Id2',
310
- * 'Name2'
311
- * ]
312
- * ];
313
- *
314
- * //-
315
- * // If the callback is omitted, we'll return a Promise.
316
- * //-
317
- * table.deleteRows(keys)
318
- * .then(function(data) {
319
- * const apiResponse = data[0];
320
- * });
321
- */
322
148
  deleteRows(keys, optionsOrCallback, cb) {
323
149
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
324
150
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
325
151
  return this._mutate('deleteRows', keys, options, callback);
326
152
  }
327
- /**
328
- * Drop the table.
329
- *
330
- * @see {@link Table#delete}
331
- * @see {@link Database#updateSchema}
332
- *
333
- * @param {object} [gaxOptions] Request configuration options.
334
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
335
- * for more details.
336
- * @param {DropTableCallback} [callback] Callback function.
337
- * @returns {Promise<DropTableResponse>}
338
- *
339
- * @example
340
- * const {Spanner} = require('@google-cloud/spanner');
341
- * const spanner = new Spanner();
342
- *
343
- * const instance = spanner.instance('my-instance');
344
- * const database = instance.database('my-database');
345
- * const table = database.table('Singers');
346
- *
347
- * table.drop(function(err, operation, apiResponse) {
348
- * if (err) {
349
- * // Error handling omitted.
350
- * }
351
- *
352
- * operation
353
- * .on('error', function(err) {})
354
- * .on('complete', function() {
355
- * // Table dropped successfully.
356
- * });
357
- * });
358
- *
359
- * //-
360
- * // If the callback is omitted, we'll return a Promise.
361
- * //-
362
- * table.drop()
363
- * .then(function(data) {
364
- * const operation = data[0];
365
- * return operation.promise();
366
- * })
367
- * .then(function() {
368
- * // Table dropped successfully.
369
- * });
370
- */
371
153
  drop(gaxOptionsOrCallback, cb) {
372
154
  const gaxOptions = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {};
373
155
  const callback = typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb;
374
156
  return this.delete(gaxOptions, callback);
375
157
  }
376
- /**
377
- * @typedef {array} InsertRowsResponse
378
- * @property {CommitResponse} 0 The commit response.
379
- */
380
- /**
381
- * @callback InsertRowsCallback
382
- * @param {?Error} error Request error, if any.
383
- * @param {CommitResponse} apiResponse The full API response.
384
- */
385
- /**
386
- * @typedef {object} InsertRowsOptions
387
- * @property {google.spanner.v1.IRequestOptions} requestOptions The request options to include
388
- * with the commit request.
389
- * @property {boolean} returnCommitStats Include statistics related to the
390
- * transaction in the {@link CommitResponse}.
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
- * Insert rows of data into this table.
397
- *
398
- * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
399
- *
400
- * @param {object|object[]} rows A map of names to values of data to insert
401
- * into this table.
402
- * @param {InsertRowsOptions|CallOptions} [options] Options for configuring the request.
403
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
404
- * for more details.
405
- * @param {InsertRowsCallback} [callback] Callback function.
406
- * @returns {Promise<InsertRowsResponse>}
407
- *
408
- * @example
409
- * const {Spanner} = require('@google-cloud/spanner');
410
- * const spanner = new Spanner();
411
- *
412
- * const instance = spanner.instance('my-instance');
413
- * const database = instance.database('my-database');
414
- * const table = database.table('Singers');
415
- *
416
- * const row = {
417
- * SingerId: 'Id3',
418
- * Name: 'Eddie Wilson'
419
- * };
420
- *
421
- * table.insert(row, function(err, apiResponse) {
422
- * if (err) {
423
- * // Error handling omitted.
424
- * }
425
- *
426
- * // Rows inserted successfully.
427
- * });
428
- *
429
- * //-
430
- * // Multiple rows can be inserted at once.
431
- * //-
432
- * const row2 = {
433
- * SingerId: 'Id3b',
434
- * Name: 'Joe West'
435
- * };
436
- *
437
- * table.insert([
438
- * row,
439
- * row2
440
- * ], function(err, apiResponse) {});
441
- *
442
- * //-
443
- * // If the callback is omitted, we'll return a Promise.
444
- * //-
445
- * table.insert(row)
446
- * .then(function(data) {
447
- * const apiResponse = data[0];
448
- * });
449
- *
450
- * @example <caption>include:samples/crud.js</caption>
451
- * region_tag:spanner_insert_data
452
- * Full example:
453
- */
454
158
  insert(rows, optionsOrCallback, cb) {
455
159
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
456
160
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
457
161
  this._mutate('insert', rows, options, callback);
458
162
  }
459
- /**
460
- * Configuration object, describing what to read from the table.
461
- */
462
- /**
463
- * @typedef {array} TableReadResponse
464
- * @property {array[]} 0 Rows are returned as an array of object arrays. Each
465
- * object has a `name` and `value` property. To get a serialized object,
466
- * call `toJSON()`. Optionally, provide an options object to `toJSON()`
467
- * specifying `wrapNumbers: true` to protect large integer values outside
468
- * of the range of JavaScript Number. If set, FLOAT64 values will be returned
469
- * as {@link Spanner.Float} objects and INT64 values as {@link
470
- * Spanner.Int}.
471
- */
472
- /**
473
- * @callback TableReadCallback
474
- * @param {?Error} err Request error, if any.
475
- * @param {array[]} rows Rows are returned as an array of object arrays. Each
476
- * object has a `name` and `value` property. To get a serialized object,
477
- * call `toJSON()`. Optionally, provide an options object to `toJSON()`
478
- * specifying `wrapNumbers: true` to protect large integer values outside
479
- * of the range of JavaScript Number. If set, FLOAT64 values will be returned
480
- * as {@link Spanner.Float} objects and INT64 values as {@link
481
- * Spanner.Int}.
482
- */
483
- /**
484
- * Receive rows from the database using key lookups and scans.
485
- *
486
- * **Performance Considerations:**
487
- *
488
- * This method wraps the streaming method,
489
- * {@link Table#createReadStream} for your convenience. All rows will
490
- * be stored in memory before being released to your callback. If you intend
491
- * on receiving a lot of results from your query, consider using the streaming
492
- * method, so you can free each result from memory after consuming it.
493
- *
494
- * @param {ReadRequest} query Configuration object, describing
495
- * what to read from the table.
496
- * @param {TimestampBounds} options [Transaction options](https://cloud.google.com/spanner/docs/timestamp-bounds).
497
- * @param {TableReadCallback} [callback] Callback function.
498
- * @returns {Promise<TableReadResponse>}
499
- *
500
- * @example
501
- * const {Spanner} = require('@google-cloud/spanner');
502
- * const spanner = new Spanner();
503
- *
504
- * const instance = spanner.instance('my-instance');
505
- * const database = instance.database('my-database');
506
- * const table = database.table('Singers');
507
- *
508
- * const query = {
509
- * keys: ['1'],
510
- * columns: ['SingerId', 'name']
511
- * };
512
- *
513
- * table.read(query, function(err, rows) {
514
- * if (err) {
515
- * // Error handling omitted.
516
- * }
517
- *
518
- * const firstRow = rows[0];
519
- *
520
- * // firstRow = [
521
- * // {
522
- * // name: 'SingerId',
523
- * // value: '1'
524
- * // },
525
- * // {
526
- * // name: 'Name',
527
- * // value: 'Eddie Wilson'
528
- * // }
529
- * // ]
530
- * });
531
- *
532
- * //-
533
- * // Provide an array for `query.keys` to read with a composite key.
534
- * //-
535
- * const query = {
536
- * keys: [
537
- * [
538
- * 'Id1',
539
- * 'Name1'
540
- * ],
541
- * [
542
- * 'Id2',
543
- * 'Name2'
544
- * ]
545
- * ],
546
- * // ...
547
- * };
548
- *
549
- * //-
550
- * // Rows are returned as an array of object arrays. Each object has a `name`
551
- * // and `value` property. To get a serialized object, call `toJSON()`.
552
- * //
553
- * // Alternatively, set `query.json` to `true`, and this step will be
554
- * performed
555
- * // automatically.
556
- * //-
557
- * table.read(query, function(err, rows) {
558
- * if (err) {
559
- * // Error handling omitted.
560
- * }
561
- *
562
- * const firstRow = rows[0];
563
- *
564
- * // firstRow.toJSON() = {
565
- * // SingerId: '1',
566
- * // Name: 'Eddie Wilson'
567
- * // }
568
- * });
569
- *
570
- * //-
571
- * // If the callback is omitted, we'll return a Promise.
572
- * //-
573
- * table.read(query)
574
- * .then(function(data) {
575
- * const rows = data[0];
576
- * });
577
- *
578
- * @example <caption>include:samples/crud.js</caption>
579
- * region_tag:spanner_read_data
580
- * Full example:
581
- *
582
- * @example <caption>include:samples/crud.js</caption>
583
- * region_tag:spanner_read_stale_data
584
- * Reading stale data:
585
- *
586
- * @example <caption>include:samples/index-read-data.js</caption>
587
- * region_tag:spanner_read_data_with_index
588
- * Reading data using an index:
589
- *
590
- * @example <caption>include:samples/index-read-data-with-storing.js</caption>
591
- * region_tag:spanner_read_data_with_storing_index
592
- * Reading data using a storing index:
593
- */
594
163
  read(request, optionsOrCallback, cb) {
595
164
  const rows = [];
596
165
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -602,204 +171,16 @@ class Table {
602
171
  .on('data', (row) => rows.push(row))
603
172
  .on('end', () => callback(null, rows));
604
173
  }
605
- /**
606
- * @typedef {array} ReplaceRowsResponse
607
- * @property {CommitResponse} 0 The commit response.
608
- */
609
- /**
610
- * @callback ReplaceRowsCallback
611
- * @param {?Error} error Request error, if any.
612
- * @param {CommitResponse} apiResponse The full API response.
613
- */
614
- /**
615
- * @typedef {object} ReplaceRowsOptions
616
- * @property {google.spanner.v1.IRequestOptions} requestOptions The request options to include
617
- * with the commit request.
618
- * @property {boolean} returnCommitStats Include statistics related to the
619
- * transaction in the {@link CommitResponse}.
620
- * @property {object} [gaxOptions]
621
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
622
- * for more details.
623
- */
624
- /**
625
- * Replace rows of data within this table.
626
- *
627
- * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
628
- *
629
- * @param {object|object[]} rows A map of names to values of data to insert
630
- * into this table.
631
- * @param {ReplaceRowsOptions|CallOptions} [options] Options for configuring the request.
632
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
633
- * for more details.
634
- * @param {ReplaceRowsCallback} [callback] Callback function.
635
- * @returns {Promise<ReplaceRowsResponse>}
636
- *
637
- * @example
638
- * const {Spanner} = require('@google-cloud/spanner');
639
- * const spanner = new Spanner();
640
- *
641
- * const instance = spanner.instance('my-instance');
642
- * const database = instance.database('my-database');
643
- * const table = database.table('Singers');
644
- *
645
- * const row = {
646
- * SingerId: 'Id3',
647
- * Name: 'Joe West'
648
- * };
649
- *
650
- * table.replace(row, function(err, apiResponse) {
651
- * if (err) {
652
- * // Error handling omitted.
653
- * }
654
- *
655
- * // Row replaced successfully.
656
- * });
657
- *
658
- * //-
659
- * // If the callback is omitted, we'll return a Promise.
660
- * //-
661
- * table.replace(row)
662
- * .then(function(data) {
663
- * const apiResponse = data[0];
664
- * });
665
- */
666
174
  replace(rows, optionsOrCallback, cb) {
667
175
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
668
176
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
669
177
  this._mutate('replace', rows, options, callback);
670
178
  }
671
- /**
672
- * @typedef {array} UpdateRowsResponse
673
- * @property {CommitResponse} 0 The commit response.
674
- */
675
- /**
676
- * @callback UpdateRowsCallback
677
- * @param {?Error} error Request error, if any.
678
- * @param {CommitResponse} apiResponse The full API response.
679
- */
680
- /**
681
- * @typedef {object} UpdateRowsOptions
682
- * @property {google.spanner.v1.IRequestOptions} requestOptions The request options to include
683
- * with the commit request.
684
- * @property {boolean} returnCommitStats Include statistics related to the
685
- * transaction in the {@link CommitResponse}.
686
- * @property {object} [gaxOptions]
687
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
688
- * for more details.
689
- */
690
- /**
691
- * Update rows of data within this table.
692
- *
693
- * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
694
- *
695
- * @param {object|object[]} rows A map of names to values of data to insert
696
- * into this table.
697
- * @param {UpdateRowsOptions|CallOptions} [options] Options for configuring the request.
698
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
699
- * for more details.
700
- * @param {UpdateRowsCallback} [callback] Callback function.
701
- * @returns {Promise<UpdateRowsResponse>}
702
- *
703
- * @example
704
- * const {Spanner} = require('@google-cloud/spanner');
705
- * const spanner = new Spanner();
706
- *
707
- * const instance = spanner.instance('my-instance');
708
- * const database = instance.database('my-database');
709
- * const table = database.table('Singers');
710
- *
711
- * const row = {
712
- * SingerId: 'Id3',
713
- * Name: 'Joe West'
714
- * };
715
- *
716
- * table.update(row, function(err, apiResponse) {
717
- * if (err) {
718
- * // Error handling omitted.
719
- * }
720
- *
721
- * // Row updated successfully.
722
- * });
723
- *
724
- * //-
725
- * // If the callback is omitted, we'll return a Promise.
726
- * //-
727
- * table.update(row)
728
- * .then(function(data) {
729
- * const apiResponse = data[0];
730
- * });
731
- *
732
- * @example <caption>include:samples/crud.js</caption>
733
- * region_tag:spanner_update_data
734
- * Full example:
735
- */
736
179
  update(rows, optionsOrCallback, cb) {
737
180
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
738
181
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
739
182
  this._mutate('update', rows, options, callback);
740
183
  }
741
- /**
742
- * @typedef {array} UpsertRowsResponse
743
- * @property {CommitResponse} 0 The commit response.
744
- */
745
- /**
746
- * @callback UpsertRowsCallback
747
- * @param {?Error} error Request error, if any.
748
- * @param {CommitResponse} apiResponse The full API response.
749
- */
750
- /**
751
- * @typedef {object} UpsertRowsOptions
752
- * @property {google.spanner.v1.IRequestOptions} requestOptions The request options to include
753
- * with the commit request.
754
- * @property {boolean} returnCommitStats Include statistics related to the
755
- * transaction in the {@link CommitResponse}.
756
- * @property {object} [gaxOptions]
757
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
758
- * for more details.
759
- */
760
- /**
761
- * Insert or update rows of data within this table.
762
- *
763
- * @see [Commit API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.Commit)
764
- *
765
- * @param {object|object[]} rows A map of names to values of data to insert
766
- * into this table.
767
- *
768
- * @param {UpsertRowsOptions|CallOptions} [options] Options for configuring the request.
769
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
770
- * for more details.
771
- * @param {UpsertRowsCallback} [callback] Callback function.
772
- * @returns {Promise<UpsertRowsResponse>}
773
- *
774
- * @example
775
- * const {Spanner} = require('@google-cloud/spanner');
776
- * const spanner = new Spanner();
777
- *
778
- * const instance = spanner.instance('my-instance');
779
- * const database = instance.database('my-database');
780
- * const table = database.table('Singers');
781
- *
782
- * const row = {
783
- * SingerId: 'Id3',
784
- * Name: 'Joe West'
785
- * };
786
- *
787
- * table.upsert(row, function(err, apiResponse) {
788
- * if (err) {
789
- * // Error handling omitted.
790
- * }
791
- *
792
- * // Row inserted or updated successfully.
793
- * });
794
- *
795
- * //-
796
- * // If the callback is omitted, we'll return a Promise.
797
- * //-
798
- * table.upsert(row)
799
- * .then(function(data) {
800
- * const apiResponse = data[0];
801
- * });
802
- */
803
184
  upsert(rows, optionsOrCallback, cb) {
804
185
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
805
186
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;