@google-cloud/spanner 5.14.0 → 5.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +55 -52
- package/build/protos/protos.d.ts +2 -1
- package/build/protos/protos.js +7 -0
- package/build/protos/protos.json +14 -1
- package/build/src/backup.d.ts +214 -0
- package/build/src/backup.js +4 -196
- package/build/src/batch-transaction.d.ts +6 -0
- package/build/src/batch-transaction.js +6 -0
- package/build/src/codec.d.ts +5 -0
- package/build/src/codec.js +16 -0
- package/build/src/database.d.ts +1244 -22
- package/build/src/database.js +36 -1184
- package/build/src/index.d.ts +366 -17
- package/build/src/index.js +39 -312
- package/build/src/instance.d.ts +526 -0
- package/build/src/instance.js +18 -498
- package/build/src/session-pool.d.ts +5 -5
- package/build/src/session-pool.js +13 -8
- package/build/src/session.d.ts +98 -0
- package/build/src/session.js +16 -82
- package/build/src/table.d.ts +645 -0
- package/build/src/table.js +4 -623
- package/build/src/transaction.d.ts +529 -19
- package/build/src/transaction.js +131 -443
- package/build/src/v1/database_admin_client.d.ts +666 -40
- package/build/src/v1/database_admin_client.js +32 -706
- package/build/src/v1/gapic_metadata.json +1 -1
- package/build/src/v1/instance_admin_client.d.ts +357 -20
- package/build/src/v1/instance_admin_client.js +16 -377
- package/build/src/v1/spanner_client.d.ts +586 -13
- package/build/src/v1/spanner_client.js +10 -596
- package/package.json +3 -3
package/build/src/index.js
CHANGED
|
@@ -62,19 +62,27 @@ const gcpApiConfig = require('./spanner_grpc_config.json');
|
|
|
62
62
|
* @see [Cloud Spanner Documentation](https://cloud.google.com/spanner/docs)
|
|
63
63
|
* @see [Cloud Spanner Concepts](https://cloud.google.com/spanner/docs/concepts)
|
|
64
64
|
*
|
|
65
|
-
* @example
|
|
66
|
-
* href="https://www.npmjs.com/">npm</a
|
|
67
|
-
*
|
|
65
|
+
* @example Install the client library with <a
|
|
66
|
+
* href="https://www.npmjs.com/">npm</a>:
|
|
67
|
+
* ```
|
|
68
|
+
* npm install --save @google-cloud/spanner
|
|
69
|
+
* ```
|
|
68
70
|
*
|
|
69
|
-
* @example
|
|
71
|
+
* @example Create a client that uses <a
|
|
70
72
|
* href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Application
|
|
71
|
-
* Default Credentials (ADC)</a
|
|
73
|
+
* Default Credentials (ADC)</a>:
|
|
74
|
+
* ```
|
|
75
|
+
* const client = new Spanner();
|
|
76
|
+
* ```
|
|
72
77
|
*
|
|
73
|
-
* @example
|
|
78
|
+
* @example Create a client with <a
|
|
74
79
|
* href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually">explicit
|
|
75
|
-
* credentials</a
|
|
80
|
+
* credentials</a>:
|
|
81
|
+
* ```
|
|
82
|
+
* const client = new Spanner({ projectId:
|
|
76
83
|
* 'your-project-id', keyFilename: '/path/to/keyfile.json'
|
|
77
84
|
* });
|
|
85
|
+
* ```
|
|
78
86
|
*
|
|
79
87
|
* @example <caption>include:samples/quickstart.js</caption>
|
|
80
88
|
* region_tag:spanner_quickstart
|
|
@@ -177,93 +185,6 @@ class Spanner extends service_1.GrpcService {
|
|
|
177
185
|
client.close();
|
|
178
186
|
});
|
|
179
187
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Config for the new instance.
|
|
182
|
-
*
|
|
183
|
-
* @typedef {object} CreateInstanceRequest
|
|
184
|
-
* @property {string} config The name of the instance's configuration.
|
|
185
|
-
* @property {number} [nodes=1] The number of nodes allocated to this instance.
|
|
186
|
-
* Defaults to 1.
|
|
187
|
-
* @property {Object.<string, string>} [labels] Labels are a flexible and
|
|
188
|
-
* lightweight mechanism for organizing cloud resources into groups that
|
|
189
|
-
* reflect a customer's organizational needs and deployment strategies.
|
|
190
|
-
* Cloud Labels can be used to filter collections of resources. They can
|
|
191
|
-
* be used to control how resource metrics are aggregated. And they can
|
|
192
|
-
* be used as arguments to policy management rules (e.g. route,
|
|
193
|
-
* firewall, load balancing, etc.).
|
|
194
|
-
* @property {string} [displayName] The descriptive name for this instance
|
|
195
|
-
* as it appears in UIs. Must be unique per project and between 4 and 30
|
|
196
|
-
* characters in length.
|
|
197
|
-
* Defaults to the instance unique identifier '<instance>' of the full
|
|
198
|
-
* instance name of the form 'projects/<project>/instances/<instance>'.
|
|
199
|
-
*/
|
|
200
|
-
/**
|
|
201
|
-
* @typedef {array} CreateInstanceResponse
|
|
202
|
-
* @property {Instance} 0 The new {@link Instance}.
|
|
203
|
-
* @property {google.longrunning.Operation} 1 An operation object that can be used to check
|
|
204
|
-
* the status of the request.
|
|
205
|
-
* @property {google.longrunning.IOperation} 2 The full API response.
|
|
206
|
-
*/
|
|
207
|
-
/**
|
|
208
|
-
* @callback CreateInstanceCallback
|
|
209
|
-
* @param {?Error} err Request error, if any.
|
|
210
|
-
* @param {Instance} instance The new {@link Instance}.
|
|
211
|
-
* @param {google.longrunning.Operation} operation An operation object that can be used to
|
|
212
|
-
* check the status of the request.
|
|
213
|
-
* @param {google.longrunning.IOperation} apiResponse The full API response.
|
|
214
|
-
*/
|
|
215
|
-
/**
|
|
216
|
-
* Create an instance.
|
|
217
|
-
*
|
|
218
|
-
* Wrapper around {@link v1.InstanceAdminClient#createInstance}.
|
|
219
|
-
*
|
|
220
|
-
* @see {@link v1.InstanceAdminClient#createInstance}
|
|
221
|
-
* @see [CreateInstace API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance)
|
|
222
|
-
*
|
|
223
|
-
* @throws {Error} If a name is not provided.
|
|
224
|
-
* @throws {Error} If a configuration object is not provided.
|
|
225
|
-
*
|
|
226
|
-
* @param {string} name The name of the instance to be created.
|
|
227
|
-
* @param {CreateInstanceRequest} config Configuration object.
|
|
228
|
-
* @param {CreateInstanceCallback} [callback] Callback function.
|
|
229
|
-
* @returns {Promise<CreateInstanceResponse>}
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
233
|
-
* const spanner = new Spanner();
|
|
234
|
-
*
|
|
235
|
-
* const config = {
|
|
236
|
-
* config: 'regional-us-central1',
|
|
237
|
-
* nodes: 1
|
|
238
|
-
* };
|
|
239
|
-
*
|
|
240
|
-
* function callback(err, instance, operation, apiResponse) {
|
|
241
|
-
* if (err) {
|
|
242
|
-
* // Error handling omitted.
|
|
243
|
-
* }
|
|
244
|
-
*
|
|
245
|
-
* operation
|
|
246
|
-
* .on('error', function(err) {})
|
|
247
|
-
* .on('complete', function() {
|
|
248
|
-
* // Instance created successfully.
|
|
249
|
-
* });
|
|
250
|
-
* }
|
|
251
|
-
*
|
|
252
|
-
* spanner.createInstance('new-instance-name', config, callback);
|
|
253
|
-
*
|
|
254
|
-
* //-
|
|
255
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
256
|
-
* //-
|
|
257
|
-
* spanner.createInstance('new-instance-name', config)
|
|
258
|
-
* .then(function(data) {
|
|
259
|
-
* const instance = data[0];
|
|
260
|
-
* const operation = data[1];
|
|
261
|
-
* return operation.promise();
|
|
262
|
-
* })
|
|
263
|
-
* .then(function() {
|
|
264
|
-
* // Instance created successfully.
|
|
265
|
-
* });
|
|
266
|
-
*/
|
|
267
188
|
createInstance(name, config, callback) {
|
|
268
189
|
if (!name) {
|
|
269
190
|
throw new Error('A name is required to create an instance.');
|
|
@@ -311,88 +232,6 @@ class Spanner extends service_1.GrpcService {
|
|
|
311
232
|
callback(null, instance, operation, resp);
|
|
312
233
|
});
|
|
313
234
|
}
|
|
314
|
-
/**
|
|
315
|
-
* Query object for listing instances.
|
|
316
|
-
*
|
|
317
|
-
* @typedef {object} GetInstancesOptions
|
|
318
|
-
* @property {object} [gaxOptions] Request configuration options,
|
|
319
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
320
|
-
* for more details.
|
|
321
|
-
* @property {string} [filter] An expression for filtering the results of the
|
|
322
|
-
* request. Filter rules are case insensitive. The fields eligible for
|
|
323
|
-
* filtering are:
|
|
324
|
-
* - **`name`**
|
|
325
|
-
* - **`display_name`**
|
|
326
|
-
* - **`labels.key`** where key is the name of a label
|
|
327
|
-
*
|
|
328
|
-
* Some examples of using filters are:
|
|
329
|
-
* - **`name:*`** The instance has a name.
|
|
330
|
-
* - **`name:Howl`** The instance's name is howl.
|
|
331
|
-
* - **`labels.env:*`** The instance has the label env.
|
|
332
|
-
* - **`labels.env:dev`** The instance's label env has the value dev.
|
|
333
|
-
* - **`name:howl labels.env:dev`** The instance's name is howl and it has
|
|
334
|
-
* the label env with value dev.
|
|
335
|
-
* @property {number} [pageSize] Maximum number of results per page.
|
|
336
|
-
* @property {string} [pageToken] A previously-returned page token
|
|
337
|
-
* representing part of the larger set of results to view.
|
|
338
|
-
*/
|
|
339
|
-
/**
|
|
340
|
-
* @typedef {array} GetInstancesResponse
|
|
341
|
-
* @property {Instance[]} 0 Array of {@link Instance} instances.
|
|
342
|
-
* @property {object} 1 A query object to receive more results.
|
|
343
|
-
* @property {object} 2 The full API response.
|
|
344
|
-
*/
|
|
345
|
-
/**
|
|
346
|
-
* @callback GetInstancesCallback
|
|
347
|
-
* @param {?Error} err Request error, if any.
|
|
348
|
-
* @param {Instance[]} instances Array of {@link Instance} instances.
|
|
349
|
-
* @param {string} nextQuery A query object to receive more results.
|
|
350
|
-
* @param {object} apiResponse The full API response.
|
|
351
|
-
*/
|
|
352
|
-
/**
|
|
353
|
-
* Get a list of instances.
|
|
354
|
-
*
|
|
355
|
-
* Wrapper around {@link v1.InstanceAdminClient#listInstances}.
|
|
356
|
-
*
|
|
357
|
-
* @see {@link v1.InstanceAdminClient#listInstances}
|
|
358
|
-
* @see [ListInstances API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.ListInstances)
|
|
359
|
-
*
|
|
360
|
-
* @param {GetInstancesOptions} [options] Query object for listing instances.
|
|
361
|
-
* @param {GetInstancesCallback} [callback] Callback function.
|
|
362
|
-
* @returns {Promise<GetInstancesResponse>}
|
|
363
|
-
*
|
|
364
|
-
* @example
|
|
365
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
366
|
-
* const spanner = new Spanner();
|
|
367
|
-
*
|
|
368
|
-
* spanner.getInstances(function(err, instances) {
|
|
369
|
-
* // `instances` is an array of `Instance` objects.
|
|
370
|
-
* });
|
|
371
|
-
*
|
|
372
|
-
* //-
|
|
373
|
-
* // To control how many API requests are made and page through the results
|
|
374
|
-
* // manually, set `autoPaginate` to `false`.
|
|
375
|
-
* //-
|
|
376
|
-
* function callback(err, instances, nextQuery, apiResponse) {
|
|
377
|
-
* if (nextQuery) {
|
|
378
|
-
* // More results exist.
|
|
379
|
-
* spanner.getInstances(nextQuery, callback);
|
|
380
|
-
* }
|
|
381
|
-
* }
|
|
382
|
-
*
|
|
383
|
-
* spanner.getInstances({
|
|
384
|
-
* gaxOptions: {
|
|
385
|
-
* autoPaginate: false,
|
|
386
|
-
* }
|
|
387
|
-
* }, callback);
|
|
388
|
-
*
|
|
389
|
-
* //-
|
|
390
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
391
|
-
* //-
|
|
392
|
-
* spanner.getInstances().then(function(data) {
|
|
393
|
-
* const instances = data[0];
|
|
394
|
-
* });
|
|
395
|
-
*/
|
|
396
235
|
getInstances(optionsOrCallback, cb) {
|
|
397
236
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
398
237
|
const self = this;
|
|
@@ -450,6 +289,7 @@ class Spanner extends service_1.GrpcService {
|
|
|
450
289
|
* instances.
|
|
451
290
|
*
|
|
452
291
|
* @example
|
|
292
|
+
* ```
|
|
453
293
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
454
294
|
* const spanner = new Spanner();
|
|
455
295
|
*
|
|
@@ -470,6 +310,7 @@ class Spanner extends service_1.GrpcService {
|
|
|
470
310
|
* .on('data', function(instance) {
|
|
471
311
|
* this.end();
|
|
472
312
|
* });
|
|
313
|
+
* ```
|
|
473
314
|
*/
|
|
474
315
|
getInstancesStream(options = {}) {
|
|
475
316
|
const gaxOpts = extend(true, {}, options.gaxOptions);
|
|
@@ -495,88 +336,6 @@ class Spanner extends service_1.GrpcService {
|
|
|
495
336
|
headers: this.resourceHeader_,
|
|
496
337
|
});
|
|
497
338
|
}
|
|
498
|
-
/**
|
|
499
|
-
* Lists the supported instance configurations for a given project.
|
|
500
|
-
*
|
|
501
|
-
* @typedef {object} GetInstanceConfigsOptions
|
|
502
|
-
* @property {number} [pageSize] Maximum number of results per page.
|
|
503
|
-
* @property {string} [pageToken] A previously-returned page token
|
|
504
|
-
* representing part of the larger set of results to view.
|
|
505
|
-
* @property {object} [gaxOptions] Request configuration options,
|
|
506
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
507
|
-
* for more details.
|
|
508
|
-
*/
|
|
509
|
-
/**
|
|
510
|
-
* @typedef {array} GetInstanceConfigsResponse
|
|
511
|
-
* @property {object[]} 0 List of all available instance configs.
|
|
512
|
-
* @property {string} 0.name The unique identifier for the instance config.
|
|
513
|
-
* @property {string} 0.displayName The name of the instance config as it
|
|
514
|
-
* appears in UIs.
|
|
515
|
-
* @property {google.spanner.admin.instance.v1.IReplicaInfo[]} 0.replicas The replicas used by
|
|
516
|
-
* this instance config.
|
|
517
|
-
* @property {string[]} 0.leaderOptions The possible leader options for this instance config.
|
|
518
|
-
* @property {object} 1 A query object to receive more results.
|
|
519
|
-
* @property {object} 2 The full API response.
|
|
520
|
-
*/
|
|
521
|
-
/**
|
|
522
|
-
* @callback GetInstanceConfigsCallback
|
|
523
|
-
* @param {?Error} err Request error, if any.
|
|
524
|
-
* @param {object[]} instanceConfigs List of all available instance configs.
|
|
525
|
-
* @param {string} instanceConfigs.name The unique identifier for the instance
|
|
526
|
-
* config.
|
|
527
|
-
* @param {string} instanceConfigs.displayName The name of the instance config
|
|
528
|
-
* as it appears in UIs.
|
|
529
|
-
* @param {google.spanner.admin.instance.v1.IReplicaInfo[]} instanceConfigs.replicas The replicas used by
|
|
530
|
-
* this instance config.
|
|
531
|
-
* @param {string[]} instanceConfigs.leaderOptions The possible leader options for this instance config.
|
|
532
|
-
* @param {object} nextQuery A query object to receive more results.
|
|
533
|
-
* @param {object} apiResponse The full API response.
|
|
534
|
-
*/
|
|
535
|
-
/**
|
|
536
|
-
* Get a list of instance configs.
|
|
537
|
-
*
|
|
538
|
-
* Wrapper around {@link v1.InstanceAdminClient#listInstanceConfigs}.
|
|
539
|
-
*
|
|
540
|
-
* @see {@link v1.InstanceAdminClient#listInstanceConfigs}
|
|
541
|
-
* @see [ListInstanceConfigs API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs)
|
|
542
|
-
*
|
|
543
|
-
* @param {GetInstanceConfigsOptions} [options] Query object for listing instance
|
|
544
|
-
* configs.
|
|
545
|
-
* @param {GetInstanceConfigsCallback} [callback] Callback function.
|
|
546
|
-
* @returns {Promise<GetInstanceConfigsResponse>}
|
|
547
|
-
*
|
|
548
|
-
* @example
|
|
549
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
550
|
-
* const spanner = new Spanner();
|
|
551
|
-
*
|
|
552
|
-
* spanner.getInstanceConfigs(function(err, instanceConfigs) {
|
|
553
|
-
* // `instanceConfigs` is an array of instance configuration descriptors.
|
|
554
|
-
* });
|
|
555
|
-
*
|
|
556
|
-
* //-
|
|
557
|
-
* // To control how many API requests are made and page through the results
|
|
558
|
-
* // manually, set `autoPaginate` to `false`.
|
|
559
|
-
* //-
|
|
560
|
-
* function callback(err, instanceConfigs, nextQuery, apiResponse) {
|
|
561
|
-
* if (nextQuery) {
|
|
562
|
-
* // More results exist.
|
|
563
|
-
* spanner.getInstanceConfigs(nextQuery, callback);
|
|
564
|
-
* }
|
|
565
|
-
* }
|
|
566
|
-
*
|
|
567
|
-
* spanner.getInstanceConfigs({
|
|
568
|
-
* gaxOptions: {
|
|
569
|
-
* autoPaginate: false,
|
|
570
|
-
* }
|
|
571
|
-
* }, callback);
|
|
572
|
-
*
|
|
573
|
-
* //-
|
|
574
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
575
|
-
* //-
|
|
576
|
-
* spanner.getInstanceConfigs().then(function(data) {
|
|
577
|
-
* const instanceConfigs = data[0];
|
|
578
|
-
* });
|
|
579
|
-
*/
|
|
580
339
|
getInstanceConfigs(optionsOrCallback, cb) {
|
|
581
340
|
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
|
|
582
341
|
const options = typeof optionsOrCallback === 'object'
|
|
@@ -624,6 +383,7 @@ class Spanner extends service_1.GrpcService {
|
|
|
624
383
|
* @returns {ReadableStream} A readable stream that emits instance configs.
|
|
625
384
|
*
|
|
626
385
|
* @example
|
|
386
|
+
* ```
|
|
627
387
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
628
388
|
* const spanner = new Spanner();
|
|
629
389
|
*
|
|
@@ -642,6 +402,7 @@ class Spanner extends service_1.GrpcService {
|
|
|
642
402
|
* .on('data', function(instanceConfig) {
|
|
643
403
|
* this.end();
|
|
644
404
|
* });
|
|
405
|
+
* ```
|
|
645
406
|
*/
|
|
646
407
|
getInstanceConfigsStream(options = {}) {
|
|
647
408
|
const gaxOpts = extend(true, {}, options.gaxOptions);
|
|
@@ -667,58 +428,6 @@ class Spanner extends service_1.GrpcService {
|
|
|
667
428
|
headers: this.resourceHeader_,
|
|
668
429
|
});
|
|
669
430
|
}
|
|
670
|
-
/**
|
|
671
|
-
* Gets the instance configuration with the specified name.
|
|
672
|
-
*/
|
|
673
|
-
/**
|
|
674
|
-
* @typedef {array} GetInstanceConfigResponse
|
|
675
|
-
* @property {object[]} 0 The metadata of the instance config.
|
|
676
|
-
* @property {string} 0.name The unique identifier for the instance config.
|
|
677
|
-
* @property {string} 0.displayName The name of the instance config as it
|
|
678
|
-
* appears in UIs.
|
|
679
|
-
* @property {google.spanner.admin.instance.v1.IReplicaInfo[]} 0.replicas The replicas used by
|
|
680
|
-
* this instance config.
|
|
681
|
-
* @property {string[]} 0.leaderOptions The possible leader options for this instance config.
|
|
682
|
-
*/
|
|
683
|
-
/**
|
|
684
|
-
* @callback GetInstanceConfigCallback
|
|
685
|
-
* @param {?Error} err Request error, if any.
|
|
686
|
-
* @param {object} instanceConfig The metadata of the instance config.
|
|
687
|
-
* @param {string} instanceConfig.name The unique identifier for the instance
|
|
688
|
-
* config.
|
|
689
|
-
* @param {string} instanceConfig.displayName The name of the instance config
|
|
690
|
-
* as it appears in UIs.
|
|
691
|
-
* @param {google.spanner.admin.instance.v1.IReplicaInfo[]} instanceConfig.replicas The replicas used by
|
|
692
|
-
* this instance config.
|
|
693
|
-
* @param {string[]} 0.leaderOptions The possible leader options for this instance config.
|
|
694
|
-
*/
|
|
695
|
-
/**
|
|
696
|
-
* Get a specific instance config.
|
|
697
|
-
*
|
|
698
|
-
* Wrapper around {@link v1.InstanceAdminClient#getInstanceConfig}.
|
|
699
|
-
*
|
|
700
|
-
* @see {@link v1.InstanceAdminClient#getInstanceConfig}
|
|
701
|
-
* @see [GetInstanceConfig API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig)
|
|
702
|
-
*
|
|
703
|
-
* @param {string} [name] The name of the instance config to get.
|
|
704
|
-
* @param {GetInstanceConfigCallback} [callback] Callback function.
|
|
705
|
-
* @returns {Promise<GetInstanceConfigResponse>}
|
|
706
|
-
*
|
|
707
|
-
* @example
|
|
708
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
709
|
-
* const spanner = new Spanner();
|
|
710
|
-
*
|
|
711
|
-
* spanner.getInstanceConfig('nam6', function(err, instanceConfig) {
|
|
712
|
-
* // `instanceConfig` is an instance configuration descriptor.
|
|
713
|
-
* });
|
|
714
|
-
*
|
|
715
|
-
* //-
|
|
716
|
-
* // If the callback is omitted, we'll return a Promise.
|
|
717
|
-
* //-
|
|
718
|
-
* spanner.getInstanceConfig().then(function(data) {
|
|
719
|
-
* const instanceConfig = data[0];
|
|
720
|
-
* });
|
|
721
|
-
*/
|
|
722
431
|
getInstanceConfig(name, optionsOrCallback, cb) {
|
|
723
432
|
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
|
|
724
433
|
const options = typeof optionsOrCallback === 'object'
|
|
@@ -747,9 +456,11 @@ class Spanner extends service_1.GrpcService {
|
|
|
747
456
|
* @returns {Instance} An Instance object.
|
|
748
457
|
*
|
|
749
458
|
* @example
|
|
459
|
+
* ```
|
|
750
460
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
751
461
|
* const spanner = new Spanner();
|
|
752
462
|
* const instance = spanner.instance('my-instance');
|
|
463
|
+
* ```
|
|
753
464
|
*/
|
|
754
465
|
instance(name) {
|
|
755
466
|
if (!name) {
|
|
@@ -892,8 +603,10 @@ class Spanner extends service_1.GrpcService {
|
|
|
892
603
|
* @returns {SpannerDate}
|
|
893
604
|
*
|
|
894
605
|
* @example
|
|
606
|
+
* ```
|
|
895
607
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
896
608
|
* const date = Spanner.date('08-20-1969');
|
|
609
|
+
* ```
|
|
897
610
|
*/
|
|
898
611
|
static date(dateStringOrYear, month, date) {
|
|
899
612
|
if (typeof dateStringOrYear === 'number') {
|
|
@@ -925,14 +638,20 @@ class Spanner extends service_1.GrpcService {
|
|
|
925
638
|
* @returns {external:PreciseDate}
|
|
926
639
|
*
|
|
927
640
|
* @example
|
|
641
|
+
* ```
|
|
928
642
|
* const timestamp = Spanner.timestamp('2019-02-08T10:34:29.481145231Z');
|
|
929
643
|
*
|
|
930
|
-
*
|
|
644
|
+
* ```
|
|
645
|
+
* @example With a `google.protobuf.Timestamp` object
|
|
646
|
+
* ```
|
|
931
647
|
* const [seconds, nanos] = process.hrtime();
|
|
932
648
|
* const timestamp = Spanner.timestamp({seconds, nanos});
|
|
649
|
+
* ```
|
|
933
650
|
*
|
|
934
|
-
* @example
|
|
651
|
+
* @example With a Date timestamp
|
|
652
|
+
* ```
|
|
935
653
|
* const timestamp = Spanner.timestamp(Date.now());
|
|
654
|
+
* ```
|
|
936
655
|
*/
|
|
937
656
|
static timestamp(value) {
|
|
938
657
|
value = value || Date.now();
|
|
@@ -948,8 +667,10 @@ class Spanner extends service_1.GrpcService {
|
|
|
948
667
|
* @returns {Float}
|
|
949
668
|
*
|
|
950
669
|
* @example
|
|
670
|
+
* ```
|
|
951
671
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
952
672
|
* const float = Spanner.float(10);
|
|
673
|
+
* ```
|
|
953
674
|
*/
|
|
954
675
|
static float(value) {
|
|
955
676
|
return new codec_1.codec.Float(value);
|
|
@@ -961,8 +682,10 @@ class Spanner extends service_1.GrpcService {
|
|
|
961
682
|
* @returns {Int}
|
|
962
683
|
*
|
|
963
684
|
* @example
|
|
685
|
+
* ```
|
|
964
686
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
965
687
|
* const int = Spanner.int(10);
|
|
688
|
+
* ```
|
|
966
689
|
*/
|
|
967
690
|
static int(value) {
|
|
968
691
|
return new codec_1.codec.Int(value);
|
|
@@ -974,8 +697,10 @@ class Spanner extends service_1.GrpcService {
|
|
|
974
697
|
* @returns {Numeric}
|
|
975
698
|
*
|
|
976
699
|
* @example
|
|
700
|
+
* ```
|
|
977
701
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
978
702
|
* const numeric = Spanner.numeric("3.141592653");
|
|
703
|
+
* ```
|
|
979
704
|
*/
|
|
980
705
|
static numeric(value) {
|
|
981
706
|
return new codec_1.codec.Numeric(value);
|
|
@@ -987,11 +712,13 @@ class Spanner extends service_1.GrpcService {
|
|
|
987
712
|
* @returns {Struct}
|
|
988
713
|
*
|
|
989
714
|
* @example
|
|
715
|
+
* ```
|
|
990
716
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
991
717
|
* const struct = Spanner.struct({
|
|
992
718
|
* user: 'bob',
|
|
993
719
|
* age: 32
|
|
994
720
|
* });
|
|
721
|
+
* ```
|
|
995
722
|
*/
|
|
996
723
|
static struct(value) {
|
|
997
724
|
if (Array.isArray(value)) {
|