@google-cloud/spanner 7.20.0 → 8.0.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/README.md +1 -0
- package/build/protos/google/spanner/admin/database/v1/backup.proto +1 -1
- package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +1 -1
- package/build/protos/google/spanner/admin/database/v1/common.proto +1 -1
- package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +1 -1
- package/build/protos/google/spanner/admin/instance/v1/common.proto +1 -1
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +1 -1
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1 -1
- package/build/protos/google/spanner/v1/commit_response.proto +1 -1
- package/build/protos/google/spanner/v1/keys.proto +1 -1
- package/build/protos/google/spanner/v1/mutation.proto +1 -1
- package/build/protos/google/spanner/v1/query_plan.proto +1 -1
- package/build/protos/google/spanner/v1/result_set.proto +55 -49
- package/build/protos/google/spanner/v1/spanner.proto +1 -1
- package/build/protos/google/spanner/v1/transaction.proto +1 -1
- package/build/protos/google/spanner/v1/type.proto +1 -1
- package/build/protos/protos.d.ts +56 -50
- package/build/protos/protos.js +1016 -331
- package/build/protos/protos.json +47 -20
- package/build/src/backup.js +7 -0
- package/build/src/batch-transaction.d.ts +48 -29
- package/build/src/batch-transaction.js +13 -98
- package/build/src/codec.js +43 -26
- package/build/src/common-grpc/service-object.js +1 -0
- package/build/src/common-grpc/service.js +25 -8
- package/build/src/database.js +77 -49
- package/build/src/helper.d.ts +9 -0
- package/build/src/helper.js +24 -0
- package/build/src/index.js +24 -13
- package/build/src/instance-config.d.ts +1 -1
- package/build/src/instance-config.js +4 -0
- package/build/src/instance.js +12 -6
- package/build/src/instrument.d.ts +2 -0
- package/build/src/instrument.js +12 -9
- package/build/src/multiplexed-session.js +7 -1
- package/build/src/partial-result-stream.js +9 -5
- package/build/src/request_id_header.js +1 -0
- package/build/src/session-factory.js +5 -2
- package/build/src/session-pool.js +23 -6
- package/build/src/session.d.ts +2 -1
- package/build/src/session.js +8 -2
- package/build/src/table.js +6 -1
- package/build/src/transaction-runner.js +12 -2
- package/build/src/transaction.d.ts +2 -1
- package/build/src/transaction.js +95 -81
- package/build/src/v1/database_admin_client.d.ts +3 -2
- package/build/src/v1/database_admin_client.js +551 -167
- package/build/src/v1/instance_admin_client.d.ts +2 -1
- package/build/src/v1/instance_admin_client.js +453 -133
- package/build/src/v1/spanner_client.d.ts +2 -1
- package/build/src/v1/spanner_client.js +283 -85
- package/build/src/v1/spanner_executor_proxy_client.d.ts +2 -1
- package/build/src/v1/spanner_executor_proxy_client.js +41 -19
- package/package.json +57 -58
package/build/protos/protos.json
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"options": {
|
|
3
|
-
"syntax": "proto3"
|
|
4
|
-
},
|
|
5
2
|
"nested": {
|
|
6
3
|
"google": {
|
|
7
4
|
"nested": {
|
|
@@ -29,6 +26,7 @@
|
|
|
29
26
|
}
|
|
30
27
|
},
|
|
31
28
|
"FileDescriptorSet": {
|
|
29
|
+
"edition": "proto2",
|
|
32
30
|
"fields": {
|
|
33
31
|
"file": {
|
|
34
32
|
"rule": "repeated",
|
|
@@ -38,6 +36,7 @@
|
|
|
38
36
|
}
|
|
39
37
|
},
|
|
40
38
|
"Edition": {
|
|
39
|
+
"edition": "proto2",
|
|
41
40
|
"values": {
|
|
42
41
|
"EDITION_UNKNOWN": 0,
|
|
43
42
|
"EDITION_PROTO2": 998,
|
|
@@ -53,6 +52,7 @@
|
|
|
53
52
|
}
|
|
54
53
|
},
|
|
55
54
|
"FileDescriptorProto": {
|
|
55
|
+
"edition": "proto2",
|
|
56
56
|
"fields": {
|
|
57
57
|
"name": {
|
|
58
58
|
"type": "string",
|
|
@@ -70,18 +70,12 @@
|
|
|
70
70
|
"publicDependency": {
|
|
71
71
|
"rule": "repeated",
|
|
72
72
|
"type": "int32",
|
|
73
|
-
"id": 10
|
|
74
|
-
"options": {
|
|
75
|
-
"packed": false
|
|
76
|
-
}
|
|
73
|
+
"id": 10
|
|
77
74
|
},
|
|
78
75
|
"weakDependency": {
|
|
79
76
|
"rule": "repeated",
|
|
80
77
|
"type": "int32",
|
|
81
|
-
"id": 11
|
|
82
|
-
"options": {
|
|
83
|
-
"packed": false
|
|
84
|
-
}
|
|
78
|
+
"id": 11
|
|
85
79
|
},
|
|
86
80
|
"messageType": {
|
|
87
81
|
"rule": "repeated",
|
|
@@ -122,6 +116,7 @@
|
|
|
122
116
|
}
|
|
123
117
|
},
|
|
124
118
|
"DescriptorProto": {
|
|
119
|
+
"edition": "proto2",
|
|
125
120
|
"fields": {
|
|
126
121
|
"name": {
|
|
127
122
|
"type": "string",
|
|
@@ -204,6 +199,7 @@
|
|
|
204
199
|
}
|
|
205
200
|
},
|
|
206
201
|
"ExtensionRangeOptions": {
|
|
202
|
+
"edition": "proto2",
|
|
207
203
|
"fields": {
|
|
208
204
|
"uninterpretedOption": {
|
|
209
205
|
"rule": "repeated",
|
|
@@ -277,6 +273,7 @@
|
|
|
277
273
|
}
|
|
278
274
|
},
|
|
279
275
|
"FieldDescriptorProto": {
|
|
276
|
+
"edition": "proto2",
|
|
280
277
|
"fields": {
|
|
281
278
|
"name": {
|
|
282
279
|
"type": "string",
|
|
@@ -356,6 +353,7 @@
|
|
|
356
353
|
}
|
|
357
354
|
},
|
|
358
355
|
"OneofDescriptorProto": {
|
|
356
|
+
"edition": "proto2",
|
|
359
357
|
"fields": {
|
|
360
358
|
"name": {
|
|
361
359
|
"type": "string",
|
|
@@ -368,6 +366,7 @@
|
|
|
368
366
|
}
|
|
369
367
|
},
|
|
370
368
|
"EnumDescriptorProto": {
|
|
369
|
+
"edition": "proto2",
|
|
371
370
|
"fields": {
|
|
372
371
|
"name": {
|
|
373
372
|
"type": "string",
|
|
@@ -409,6 +408,7 @@
|
|
|
409
408
|
}
|
|
410
409
|
},
|
|
411
410
|
"EnumValueDescriptorProto": {
|
|
411
|
+
"edition": "proto2",
|
|
412
412
|
"fields": {
|
|
413
413
|
"name": {
|
|
414
414
|
"type": "string",
|
|
@@ -425,6 +425,7 @@
|
|
|
425
425
|
}
|
|
426
426
|
},
|
|
427
427
|
"ServiceDescriptorProto": {
|
|
428
|
+
"edition": "proto2",
|
|
428
429
|
"fields": {
|
|
429
430
|
"name": {
|
|
430
431
|
"type": "string",
|
|
@@ -442,6 +443,7 @@
|
|
|
442
443
|
}
|
|
443
444
|
},
|
|
444
445
|
"MethodDescriptorProto": {
|
|
446
|
+
"edition": "proto2",
|
|
445
447
|
"fields": {
|
|
446
448
|
"name": {
|
|
447
449
|
"type": "string",
|
|
@@ -476,6 +478,7 @@
|
|
|
476
478
|
}
|
|
477
479
|
},
|
|
478
480
|
"FileOptions": {
|
|
481
|
+
"edition": "proto2",
|
|
479
482
|
"fields": {
|
|
480
483
|
"javaPackage": {
|
|
481
484
|
"type": "string",
|
|
@@ -617,6 +620,7 @@
|
|
|
617
620
|
}
|
|
618
621
|
},
|
|
619
622
|
"MessageOptions": {
|
|
623
|
+
"edition": "proto2",
|
|
620
624
|
"fields": {
|
|
621
625
|
"messageSetWireFormat": {
|
|
622
626
|
"type": "bool",
|
|
@@ -690,6 +694,7 @@
|
|
|
690
694
|
]
|
|
691
695
|
},
|
|
692
696
|
"FieldOptions": {
|
|
697
|
+
"edition": "proto2",
|
|
693
698
|
"fields": {
|
|
694
699
|
"ctype": {
|
|
695
700
|
"type": "CType",
|
|
@@ -751,10 +756,7 @@
|
|
|
751
756
|
"targets": {
|
|
752
757
|
"rule": "repeated",
|
|
753
758
|
"type": "OptionTargetType",
|
|
754
|
-
"id": 19
|
|
755
|
-
"options": {
|
|
756
|
-
"packed": false
|
|
757
|
-
}
|
|
759
|
+
"id": 19
|
|
758
760
|
},
|
|
759
761
|
"editionDefaults": {
|
|
760
762
|
"rule": "repeated",
|
|
@@ -838,6 +840,7 @@
|
|
|
838
840
|
}
|
|
839
841
|
},
|
|
840
842
|
"OneofOptions": {
|
|
843
|
+
"edition": "proto2",
|
|
841
844
|
"fields": {
|
|
842
845
|
"features": {
|
|
843
846
|
"type": "FeatureSet",
|
|
@@ -857,6 +860,7 @@
|
|
|
857
860
|
]
|
|
858
861
|
},
|
|
859
862
|
"EnumOptions": {
|
|
863
|
+
"edition": "proto2",
|
|
860
864
|
"fields": {
|
|
861
865
|
"allowAlias": {
|
|
862
866
|
"type": "bool",
|
|
@@ -900,6 +904,7 @@
|
|
|
900
904
|
]
|
|
901
905
|
},
|
|
902
906
|
"EnumValueOptions": {
|
|
907
|
+
"edition": "proto2",
|
|
903
908
|
"fields": {
|
|
904
909
|
"deprecated": {
|
|
905
910
|
"type": "bool",
|
|
@@ -933,6 +938,7 @@
|
|
|
933
938
|
]
|
|
934
939
|
},
|
|
935
940
|
"ServiceOptions": {
|
|
941
|
+
"edition": "proto2",
|
|
936
942
|
"fields": {
|
|
937
943
|
"features": {
|
|
938
944
|
"type": "FeatureSet",
|
|
@@ -959,6 +965,7 @@
|
|
|
959
965
|
]
|
|
960
966
|
},
|
|
961
967
|
"MethodOptions": {
|
|
968
|
+
"edition": "proto2",
|
|
962
969
|
"fields": {
|
|
963
970
|
"deprecated": {
|
|
964
971
|
"type": "bool",
|
|
@@ -1001,6 +1008,7 @@
|
|
|
1001
1008
|
}
|
|
1002
1009
|
},
|
|
1003
1010
|
"UninterpretedOption": {
|
|
1011
|
+
"edition": "proto2",
|
|
1004
1012
|
"fields": {
|
|
1005
1013
|
"name": {
|
|
1006
1014
|
"rule": "repeated",
|
|
@@ -1050,6 +1058,7 @@
|
|
|
1050
1058
|
}
|
|
1051
1059
|
},
|
|
1052
1060
|
"FeatureSet": {
|
|
1061
|
+
"edition": "proto2",
|
|
1053
1062
|
"fields": {
|
|
1054
1063
|
"fieldPresence": {
|
|
1055
1064
|
"type": "FieldPresence",
|
|
@@ -1191,6 +1200,7 @@
|
|
|
1191
1200
|
}
|
|
1192
1201
|
},
|
|
1193
1202
|
"FeatureSetDefaults": {
|
|
1203
|
+
"edition": "proto2",
|
|
1194
1204
|
"fields": {
|
|
1195
1205
|
"defaults": {
|
|
1196
1206
|
"rule": "repeated",
|
|
@@ -1222,6 +1232,7 @@
|
|
|
1222
1232
|
}
|
|
1223
1233
|
},
|
|
1224
1234
|
"SourceCodeInfo": {
|
|
1235
|
+
"edition": "proto2",
|
|
1225
1236
|
"fields": {
|
|
1226
1237
|
"location": {
|
|
1227
1238
|
"rule": "repeated",
|
|
@@ -1235,12 +1246,18 @@
|
|
|
1235
1246
|
"path": {
|
|
1236
1247
|
"rule": "repeated",
|
|
1237
1248
|
"type": "int32",
|
|
1238
|
-
"id": 1
|
|
1249
|
+
"id": 1,
|
|
1250
|
+
"options": {
|
|
1251
|
+
"packed": true
|
|
1252
|
+
}
|
|
1239
1253
|
},
|
|
1240
1254
|
"span": {
|
|
1241
1255
|
"rule": "repeated",
|
|
1242
1256
|
"type": "int32",
|
|
1243
|
-
"id": 2
|
|
1257
|
+
"id": 2,
|
|
1258
|
+
"options": {
|
|
1259
|
+
"packed": true
|
|
1260
|
+
}
|
|
1244
1261
|
},
|
|
1245
1262
|
"leadingComments": {
|
|
1246
1263
|
"type": "string",
|
|
@@ -1260,6 +1277,7 @@
|
|
|
1260
1277
|
}
|
|
1261
1278
|
},
|
|
1262
1279
|
"GeneratedCodeInfo": {
|
|
1280
|
+
"edition": "proto2",
|
|
1263
1281
|
"fields": {
|
|
1264
1282
|
"annotation": {
|
|
1265
1283
|
"rule": "repeated",
|
|
@@ -1273,7 +1291,10 @@
|
|
|
1273
1291
|
"path": {
|
|
1274
1292
|
"rule": "repeated",
|
|
1275
1293
|
"type": "int32",
|
|
1276
|
-
"id": 1
|
|
1294
|
+
"id": 1,
|
|
1295
|
+
"options": {
|
|
1296
|
+
"packed": true
|
|
1297
|
+
}
|
|
1277
1298
|
},
|
|
1278
1299
|
"sourceFile": {
|
|
1279
1300
|
"type": "string",
|
|
@@ -7652,8 +7673,7 @@
|
|
|
7652
7673
|
"php_namespace": "Google\\Cloud\\Spanner\\V1",
|
|
7653
7674
|
"ruby_package": "Google::Cloud::Spanner::V1",
|
|
7654
7675
|
"(google.api.resource_definition).type": "spanner.googleapis.com/Database",
|
|
7655
|
-
"(google.api.resource_definition).pattern": "projects/{project}/instances/{instance}/databases/{database}"
|
|
7656
|
-
"cc_enable_arenas": true
|
|
7676
|
+
"(google.api.resource_definition).pattern": "projects/{project}/instances/{instance}/databases/{database}"
|
|
7657
7677
|
},
|
|
7658
7678
|
"nested": {
|
|
7659
7679
|
"Spanner": {
|
|
@@ -9134,6 +9154,13 @@
|
|
|
9134
9154
|
"options": {
|
|
9135
9155
|
"(google.api.field_behavior)": "OPTIONAL"
|
|
9136
9156
|
}
|
|
9157
|
+
},
|
|
9158
|
+
"last": {
|
|
9159
|
+
"type": "bool",
|
|
9160
|
+
"id": 9,
|
|
9161
|
+
"options": {
|
|
9162
|
+
"(google.api.field_behavior)": "OPTIONAL"
|
|
9163
|
+
}
|
|
9137
9164
|
}
|
|
9138
9165
|
}
|
|
9139
9166
|
},
|
package/build/src/backup.js
CHANGED
|
@@ -45,6 +45,13 @@ const precise_date_1 = require("@google-cloud/precise-date");
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
class Backup {
|
|
48
|
+
id;
|
|
49
|
+
formattedName_;
|
|
50
|
+
instanceFormattedName_;
|
|
51
|
+
resourceHeader_;
|
|
52
|
+
request;
|
|
53
|
+
metadata;
|
|
54
|
+
sourceName;
|
|
48
55
|
constructor(instance, name, sourceName) {
|
|
49
56
|
this.request = instance.request;
|
|
50
57
|
this.instanceFormattedName_ = instance.formattedName_;
|
|
@@ -13,14 +13,25 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Snapshot } from './transaction';
|
|
16
|
+
import { ExecuteSqlRequest, ReadCallback, ReadRequest, ReadResponse, RunCallback, RunResponse, Snapshot } from './transaction';
|
|
17
17
|
import { google } from '../protos/protos';
|
|
18
18
|
import { Session } from '.';
|
|
19
|
+
import { ResourceCallback } from '../src/common';
|
|
19
20
|
export interface TransactionIdentifier {
|
|
20
21
|
session: string | Session;
|
|
21
22
|
transaction?: string;
|
|
22
23
|
timestamp?: google.protobuf.ITimestamp;
|
|
23
24
|
}
|
|
25
|
+
export type CreateReadPartitionsResponse = [
|
|
26
|
+
ReadRequest[],
|
|
27
|
+
google.spanner.v1.IPartitionResponse
|
|
28
|
+
];
|
|
29
|
+
export type CreateReadPartitionsCallback = ResourceCallback<ReadRequest[], google.spanner.v1.IPartitionResponse>;
|
|
30
|
+
export type CreateQueryPartitionsResponse = [
|
|
31
|
+
ExecuteSqlRequest[],
|
|
32
|
+
google.spanner.v1.IPartitionResponse
|
|
33
|
+
];
|
|
34
|
+
export type CreateQueryPartitionsCallback = ResourceCallback<ExecuteSqlRequest[], google.spanner.v1.IPartitionResponse>;
|
|
24
35
|
/**
|
|
25
36
|
* Use a BatchTransaction object to create partitions and read/query against
|
|
26
37
|
* your Cloud Spanner database.
|
|
@@ -75,17 +86,17 @@ declare class BatchTransaction extends Snapshot {
|
|
|
75
86
|
/**
|
|
76
87
|
* @see [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
|
|
77
88
|
* @typedef {object} QueryPartition
|
|
78
|
-
* @property {string} partitionToken
|
|
89
|
+
* @property {string} partitionToken A token representing the partition, used to identify and execute the partition at a later time.
|
|
79
90
|
*/
|
|
80
91
|
/**
|
|
81
92
|
* @typedef {array} CreateQueryPartitionsResponse
|
|
82
|
-
* @property {
|
|
93
|
+
* @property {ExecuteSqlRequest[]} 0 Array of ExecuteSqlRequest partitions.
|
|
83
94
|
* @property {object} 1 The full API response.
|
|
84
95
|
*/
|
|
85
96
|
/**
|
|
86
97
|
* @callback CreateQueryPartitionsCallback
|
|
87
98
|
* @param {?Error} err Request error, if any.
|
|
88
|
-
* @param {
|
|
99
|
+
* @param {ExecuteSqlRequest[]} partitions Array of ExecuteSqlRequest partitions.
|
|
89
100
|
* @param {object} apiResponse The full API response.
|
|
90
101
|
*/
|
|
91
102
|
/**
|
|
@@ -93,22 +104,23 @@ declare class BatchTransaction extends Snapshot {
|
|
|
93
104
|
* operation in parallel. Partitions become invalid when the transaction used
|
|
94
105
|
* to create them is closed.
|
|
95
106
|
*
|
|
96
|
-
* @param {string|
|
|
97
|
-
*
|
|
98
|
-
* object.
|
|
107
|
+
* @param {string|ExecuteSqlRequest} query - A SQL query string or an {@link ExecuteSqlRequest} object.
|
|
108
|
+
* If a string is provided, it will be wrapped into an `ExecuteSqlRequest`.
|
|
99
109
|
* @param {object} [query.gaxOptions] Request configuration options,
|
|
100
110
|
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
101
111
|
* for more details.
|
|
102
112
|
* @param {object} [query.params] A map of parameter name to values.
|
|
103
113
|
* @param {object} [query.partitionOptions] A map of partition options.
|
|
104
114
|
* @param {object} [query.types] A map of parameter types.
|
|
105
|
-
* @param {CreateQueryPartitionsCallback} [callback] Callback
|
|
106
|
-
* @returns {Promise<CreateQueryPartitionsResponse
|
|
115
|
+
* @param {CreateQueryPartitionsCallback} [callback] - Optional Callback function. If not provided, a promise is returned.
|
|
116
|
+
* @returns {Promise<CreateQueryPartitionsResponse>|void} A promise resolving to an array of
|
|
117
|
+
* `ExecuteSqlRequest' partitions and `IPartitionResponse` , or void if a callback is provided.
|
|
107
118
|
*
|
|
108
119
|
* @example <caption>include:samples/batch.js</caption>
|
|
109
120
|
* region_tag:spanner_batch_client
|
|
110
121
|
*/
|
|
111
|
-
createQueryPartitions(query:
|
|
122
|
+
createQueryPartitions(query: string | ExecuteSqlRequest): Promise<CreateQueryPartitionsResponse>;
|
|
123
|
+
createQueryPartitions(query: string | ExecuteSqlRequest, callback: CreateQueryPartitionsCallback): void;
|
|
112
124
|
protected getDBName(): string;
|
|
113
125
|
/**
|
|
114
126
|
* Generic create partition method. Handles common parameters used in both
|
|
@@ -124,20 +136,20 @@ declare class BatchTransaction extends Snapshot {
|
|
|
124
136
|
/**
|
|
125
137
|
* @typedef {object} ReadPartition
|
|
126
138
|
* @mixes ReadRequestOptions
|
|
127
|
-
* @property {string} partitionToken
|
|
128
|
-
* @property {object} [gaxOptions]
|
|
129
|
-
*
|
|
139
|
+
* @property {string} partitionToken partitionToken A token representing the partition, used to identify and execute the partition at a later time.
|
|
140
|
+
* @property {object} [gaxOptions] optional request configuration options,
|
|
141
|
+
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
130
142
|
* for more details.
|
|
131
143
|
*/
|
|
132
144
|
/**
|
|
133
145
|
* @typedef {array} CreateReadPartitionsResponse
|
|
134
|
-
* @property {ReadPartition[]} 0
|
|
146
|
+
* @property {ReadPartition[]} 0 Array of read partitions.
|
|
135
147
|
* @property {object} 1 The full API response.
|
|
136
148
|
*/
|
|
137
149
|
/**
|
|
138
150
|
* @callback CreateReadPartitionsCallback
|
|
139
151
|
* @param {?Error} err Request error, if any.
|
|
140
|
-
* @param {ReadPartition[]} partitions
|
|
152
|
+
* @param {ReadPartition[]} partitions Array of read partitions.
|
|
141
153
|
* @param {object} apiResponse The full API response.
|
|
142
154
|
*/
|
|
143
155
|
/**
|
|
@@ -145,30 +157,37 @@ declare class BatchTransaction extends Snapshot {
|
|
|
145
157
|
* operation in parallel. Partitions become invalid when the transaction used
|
|
146
158
|
* to create them is closed.
|
|
147
159
|
*
|
|
148
|
-
* @param {
|
|
160
|
+
* @param {ReadRequest} options Configuration object, describing what to
|
|
149
161
|
* read from.
|
|
150
162
|
* @param {CreateReadPartitionsCallback} [callback] Callback function.
|
|
151
|
-
* @returns {Promise<CreateReadPartitionsResponse
|
|
163
|
+
* @returns {Promise<CreateReadPartitionsResponse>|void} A promise that resolves
|
|
164
|
+
* to an array containing the read partitions and the full API response, or `void` if a callback is provided.
|
|
152
165
|
*/
|
|
153
|
-
createReadPartitions(options:
|
|
166
|
+
createReadPartitions(options: ReadRequest): Promise<CreateReadPartitionsResponse>;
|
|
167
|
+
createReadPartitions(options: ReadRequest, callback: CreateReadPartitionsCallback): void;
|
|
154
168
|
/**
|
|
155
|
-
* Executes partition.
|
|
169
|
+
* Executes partition using either a read or a SQL query, depending on the type of partition provided.
|
|
156
170
|
*
|
|
157
|
-
* @
|
|
158
|
-
*
|
|
171
|
+
* @param {ReadRequest|ExecuteSqlRequest} partition The partition object to execute.
|
|
172
|
+
* This can either be a `ReadPartition` or a `QueryPartition`.
|
|
159
173
|
*
|
|
160
|
-
* @param {
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* @
|
|
165
|
-
*
|
|
166
|
-
* @
|
|
174
|
+
* @param {ReadCallback|RunCallback} [callback] Optional Callback function. If not provided,
|
|
175
|
+
* a promise will be returned.
|
|
176
|
+
*
|
|
177
|
+
* If the partition is a read partition, it will execute a read using {@link Transaction#read}
|
|
178
|
+
* @see {@link Transaction#read} when using {@link ReadRequest}.
|
|
179
|
+
*
|
|
180
|
+
* If the partition is query partition, it will execute a SQL query using {@link Transaction#run}
|
|
181
|
+
* @see {@link Transaction#run} when using {@link ExecuteSqlRequest}.
|
|
182
|
+
*
|
|
183
|
+
* @returns {Promise<ReadResponse | RunResponse>|void} Returns a promise when no callback is provided,
|
|
184
|
+
* or void when a callback is used.
|
|
167
185
|
*
|
|
168
186
|
* @example <caption>include:samples/batch.js</caption>
|
|
169
187
|
* region_tag:spanner_batch_execute_partitions
|
|
170
188
|
*/
|
|
171
|
-
execute(partition:
|
|
189
|
+
execute(partition: ReadRequest | ExecuteSqlRequest): Promise<ReadResponse | RunResponse>;
|
|
190
|
+
execute(partition: ReadRequest | ExecuteSqlRequest, callback: ReadCallback | RunCallback): void;
|
|
172
191
|
/**
|
|
173
192
|
* Executes partition in streaming mode.
|
|
174
193
|
*
|
|
@@ -80,53 +80,13 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
80
80
|
callback();
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
* @property {string} partitionToken The partition token.
|
|
87
|
-
*/
|
|
88
|
-
/**
|
|
89
|
-
* @typedef {array} CreateQueryPartitionsResponse
|
|
90
|
-
* @property {QueryPartition[]} 0 List of query partitions.
|
|
91
|
-
* @property {object} 1 The full API response.
|
|
92
|
-
*/
|
|
93
|
-
/**
|
|
94
|
-
* @callback CreateQueryPartitionsCallback
|
|
95
|
-
* @param {?Error} err Request error, if any.
|
|
96
|
-
* @param {QueryPartition[]} partitions List of query partitions.
|
|
97
|
-
* @param {object} apiResponse The full API response.
|
|
98
|
-
*/
|
|
99
|
-
/**
|
|
100
|
-
* Creates a set of query partitions that can be used to execute a query
|
|
101
|
-
* operation in parallel. Partitions become invalid when the transaction used
|
|
102
|
-
* to create them is closed.
|
|
103
|
-
*
|
|
104
|
-
* @param {string|object} query A SQL query or
|
|
105
|
-
* [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
|
|
106
|
-
* object.
|
|
107
|
-
* @param {object} [query.gaxOptions] Request configuration options,
|
|
108
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
109
|
-
* for more details.
|
|
110
|
-
* @param {object} [query.params] A map of parameter name to values.
|
|
111
|
-
* @param {object} [query.partitionOptions] A map of partition options.
|
|
112
|
-
* @param {object} [query.types] A map of parameter types.
|
|
113
|
-
* @param {CreateQueryPartitionsCallback} [callback] Callback callback function.
|
|
114
|
-
* @returns {Promise<CreateQueryPartitionsResponse>}
|
|
115
|
-
*
|
|
116
|
-
* @example <caption>include:samples/batch.js</caption>
|
|
117
|
-
* region_tag:spanner_batch_client
|
|
118
|
-
*/
|
|
119
|
-
createQueryPartitions(query, callback) {
|
|
120
|
-
if (is.string(query)) {
|
|
121
|
-
query = {
|
|
122
|
-
sql: query,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
const reqOpts = Object.assign({}, query, transaction_1.Snapshot.encodeParams(query));
|
|
83
|
+
createQueryPartitions(query, cb) {
|
|
84
|
+
const request = typeof query === 'string' ? { sql: query } : query;
|
|
85
|
+
const reqOpts = Object.assign({}, request, transaction_1.Snapshot.encodeParams(request));
|
|
126
86
|
delete reqOpts.gaxOptions;
|
|
127
87
|
delete reqOpts.types;
|
|
128
88
|
const traceConfig = {
|
|
129
|
-
sql:
|
|
89
|
+
sql: request.sql,
|
|
130
90
|
opts: this._observabilityOptions,
|
|
131
91
|
dbName: this.getDBName(),
|
|
132
92
|
};
|
|
@@ -139,14 +99,14 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
139
99
|
client: 'SpannerClient',
|
|
140
100
|
method: 'partitionQuery',
|
|
141
101
|
reqOpts,
|
|
142
|
-
gaxOpts:
|
|
102
|
+
gaxOpts: request.gaxOptions,
|
|
143
103
|
headers: (0, request_id_header_1.injectRequestIDIntoHeaders)(headers, this.session),
|
|
144
104
|
}, (err, partitions, resp) => {
|
|
145
105
|
if (err) {
|
|
146
106
|
(0, instrument_1.setSpanError)(span, err);
|
|
147
107
|
}
|
|
148
108
|
span.end();
|
|
149
|
-
|
|
109
|
+
cb(err, partitions, resp);
|
|
150
110
|
});
|
|
151
111
|
});
|
|
152
112
|
}
|
|
@@ -203,36 +163,7 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
203
163
|
});
|
|
204
164
|
});
|
|
205
165
|
}
|
|
206
|
-
|
|
207
|
-
* @typedef {object} ReadPartition
|
|
208
|
-
* @mixes ReadRequestOptions
|
|
209
|
-
* @property {string} partitionToken The partition token.
|
|
210
|
-
* @property {object} [gaxOptions] Request configuration options,
|
|
211
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
212
|
-
* for more details.
|
|
213
|
-
*/
|
|
214
|
-
/**
|
|
215
|
-
* @typedef {array} CreateReadPartitionsResponse
|
|
216
|
-
* @property {ReadPartition[]} 0 List of read partitions.
|
|
217
|
-
* @property {object} 1 The full API response.
|
|
218
|
-
*/
|
|
219
|
-
/**
|
|
220
|
-
* @callback CreateReadPartitionsCallback
|
|
221
|
-
* @param {?Error} err Request error, if any.
|
|
222
|
-
* @param {ReadPartition[]} partitions List of read partitions.
|
|
223
|
-
* @param {object} apiResponse The full API response.
|
|
224
|
-
*/
|
|
225
|
-
/**
|
|
226
|
-
* Creates a set of read partitions that can be used to execute a read
|
|
227
|
-
* operation in parallel. Partitions become invalid when the transaction used
|
|
228
|
-
* to create them is closed.
|
|
229
|
-
*
|
|
230
|
-
* @param {ReadRequestOptions} options Configuration object, describing what to
|
|
231
|
-
* read from.
|
|
232
|
-
* @param {CreateReadPartitionsCallback} [callback] Callback function.
|
|
233
|
-
* @returns {Promise<CreateReadPartitionsResponse>}
|
|
234
|
-
*/
|
|
235
|
-
createReadPartitions(options, callback) {
|
|
166
|
+
createReadPartitions(options, cb) {
|
|
236
167
|
const traceConfig = {
|
|
237
168
|
opts: this._observabilityOptions,
|
|
238
169
|
dbName: this.getDBName(),
|
|
@@ -259,33 +190,17 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
259
190
|
(0, instrument_1.setSpanError)(span, err);
|
|
260
191
|
}
|
|
261
192
|
span.end();
|
|
262
|
-
|
|
193
|
+
cb(err, partitions, resp);
|
|
263
194
|
});
|
|
264
195
|
});
|
|
265
196
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
* @see {@link Transaction#run} when using {@link QueryParition}.
|
|
271
|
-
*
|
|
272
|
-
* @param {ReadPartition|QueryParition} partition The partition object.
|
|
273
|
-
* @param {object} [partition.gaxOptions] Request configuration options,
|
|
274
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
275
|
-
* for more details.
|
|
276
|
-
* @param {TransactionRequestReadCallback|RunCallback} [callback] Callback
|
|
277
|
-
* function.
|
|
278
|
-
* @returns {Promise<RunResponse>|Promise<TransactionRequestReadResponse>}
|
|
279
|
-
*
|
|
280
|
-
* @example <caption>include:samples/batch.js</caption>
|
|
281
|
-
* region_tag:spanner_batch_execute_partitions
|
|
282
|
-
*/
|
|
283
|
-
execute(partition, callback) {
|
|
284
|
-
if (is.string(partition.table)) {
|
|
285
|
-
this.read(partition.table, partition, callback);
|
|
197
|
+
execute(partition, cb) {
|
|
198
|
+
const isRead = typeof partition.table === 'string';
|
|
199
|
+
if (isRead) {
|
|
200
|
+
this.read(partition.table, partition, cb);
|
|
286
201
|
return;
|
|
287
202
|
}
|
|
288
|
-
this.run(partition,
|
|
203
|
+
this.run(partition, cb);
|
|
289
204
|
}
|
|
290
205
|
/**
|
|
291
206
|
* Executes partition in streaming mode.
|