@google-cloud/spanner 5.15.2 → 5.16.3
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 +41 -0
- package/README.md +57 -57
- package/build/protos/protos.d.ts +3 -2
- package/build/protos/protos.js +8 -1
- 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 +4 -0
- package/build/src/codec.js +6 -1
- package/build/src/database.d.ts +1245 -23
- package/build/src/database.js +38 -1186
- package/build/src/index.d.ts +367 -18
- package/build/src/index.js +46 -319
- package/build/src/instance.d.ts +528 -2
- package/build/src/instance.js +24 -503
- package/build/src/partial-result-stream.d.ts +1 -1
- package/build/src/partial-result-stream.js +5 -1
- package/build/src/session-pool.d.ts +8 -8
- package/build/src/session-pool.js +6 -6
- 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 +509 -19
- package/build/src/transaction.js +61 -444
- 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
|
@@ -127,7 +127,7 @@ export declare class PartialResultStream extends Transform implements ResultEven
|
|
|
127
127
|
*
|
|
128
128
|
* @param {Error} [err] Optional error to destroy stream with.
|
|
129
129
|
*/
|
|
130
|
-
destroy(err?: Error):
|
|
130
|
+
destroy(err?: Error): this;
|
|
131
131
|
/**
|
|
132
132
|
* Processes each chunk.
|
|
133
133
|
*
|
|
@@ -51,7 +51,7 @@ class PartialResultStream extends stream_1.Transform {
|
|
|
51
51
|
*/
|
|
52
52
|
destroy(err) {
|
|
53
53
|
if (this._destroyed) {
|
|
54
|
-
return;
|
|
54
|
+
return this;
|
|
55
55
|
}
|
|
56
56
|
this._destroyed = true;
|
|
57
57
|
process.nextTick(() => {
|
|
@@ -60,6 +60,7 @@ class PartialResultStream extends stream_1.Transform {
|
|
|
60
60
|
}
|
|
61
61
|
this.emit('close');
|
|
62
62
|
});
|
|
63
|
+
return this;
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
66
|
* Processes each chunk.
|
|
@@ -224,6 +225,9 @@ class PartialResultStream extends stream_1.Transform {
|
|
|
224
225
|
type.code === 'ARRAY' ||
|
|
225
226
|
type.code === protos_1.google.spanner.v1.TypeCode.STRUCT ||
|
|
226
227
|
type.code === 'STRUCT') {
|
|
228
|
+
if (head === null || tail === null) {
|
|
229
|
+
return [head, tail];
|
|
230
|
+
}
|
|
227
231
|
return [PartialResultStream.mergeLists(type, head, tail)];
|
|
228
232
|
}
|
|
229
233
|
if (is.string(head) && is.string(tail)) {
|
|
@@ -20,7 +20,7 @@ import { Database } from './database';
|
|
|
20
20
|
import { Session, types } from './session';
|
|
21
21
|
import { Transaction } from './transaction';
|
|
22
22
|
import { NormalCallback } from './common';
|
|
23
|
-
import { grpc } from 'google-gax';
|
|
23
|
+
import { GoogleError, grpc } from 'google-gax';
|
|
24
24
|
import trace = require('stack-trace');
|
|
25
25
|
/**
|
|
26
26
|
* @callback SessionPoolCloseCallback
|
|
@@ -64,34 +64,34 @@ export interface SessionPoolInterface extends EventEmitter {
|
|
|
64
64
|
* @name SessionPoolInterface#close
|
|
65
65
|
* @param {SessionPoolCloseCallback} callback The callback function.
|
|
66
66
|
*/
|
|
67
|
-
close(callback: SessionPoolCloseCallback): void;
|
|
68
67
|
/**
|
|
69
68
|
* Will be called by the Database object, should be used to start creating
|
|
70
69
|
* sessions/etc.
|
|
71
70
|
*
|
|
72
71
|
* @name SessionPoolInterface#open
|
|
73
72
|
*/
|
|
74
|
-
open(): void;
|
|
75
73
|
/**
|
|
76
74
|
* When called returns a read-only session.
|
|
77
75
|
*
|
|
78
76
|
* @name SessionPoolInterface#getReadSession
|
|
79
77
|
* @param {GetReadSessionCallback} callback The callback function.
|
|
80
78
|
*/
|
|
81
|
-
getReadSession(callback: GetReadSessionCallback): void;
|
|
82
79
|
/**
|
|
83
80
|
* When called returns a read-write session with prepared transaction.
|
|
84
81
|
*
|
|
85
82
|
* @name SessionPoolInterface#getWriteSession
|
|
86
83
|
* @param {GetWriteSessionCallback} callback The callback function.
|
|
87
84
|
*/
|
|
88
|
-
getWriteSession(callback: GetWriteSessionCallback): void;
|
|
89
85
|
/**
|
|
90
86
|
* To be called when releasing a session back into the pool.
|
|
91
87
|
*
|
|
92
88
|
* @name SessionPoolInterface#release
|
|
93
89
|
* @param {Session} session The session to be released.
|
|
94
90
|
*/
|
|
91
|
+
close(callback: SessionPoolCloseCallback): void;
|
|
92
|
+
open(): void;
|
|
93
|
+
getReadSession(callback: GetReadSessionCallback): void;
|
|
94
|
+
getWriteSession(callback: GetWriteSessionCallback): void;
|
|
95
95
|
release(session: Session): void;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
@@ -142,7 +142,7 @@ export interface SessionPoolOptions {
|
|
|
142
142
|
*
|
|
143
143
|
* @private
|
|
144
144
|
*/
|
|
145
|
-
export declare class ReleaseError extends
|
|
145
|
+
export declare class ReleaseError extends GoogleError {
|
|
146
146
|
resource: unknown;
|
|
147
147
|
constructor(resource: unknown);
|
|
148
148
|
}
|
|
@@ -151,14 +151,14 @@ export declare class ReleaseError extends Error {
|
|
|
151
151
|
*
|
|
152
152
|
* @private
|
|
153
153
|
*/
|
|
154
|
-
export declare class SessionLeakError extends
|
|
154
|
+
export declare class SessionLeakError extends GoogleError {
|
|
155
155
|
messages: string[];
|
|
156
156
|
constructor(leaks: string[]);
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* Error to be thrown when the session pool is exhausted.
|
|
160
160
|
*/
|
|
161
|
-
export declare class SessionPoolExhaustedError extends
|
|
161
|
+
export declare class SessionPoolExhaustedError extends GoogleError {
|
|
162
162
|
messages: string[];
|
|
163
163
|
constructor(leaks: string[]);
|
|
164
164
|
}
|
|
@@ -39,7 +39,7 @@ const DEFAULTS = {
|
|
|
39
39
|
*
|
|
40
40
|
* @private
|
|
41
41
|
*/
|
|
42
|
-
class ReleaseError extends
|
|
42
|
+
class ReleaseError extends google_gax_1.GoogleError {
|
|
43
43
|
constructor(resource) {
|
|
44
44
|
super('Unable to release unknown resource.');
|
|
45
45
|
this.resource = resource;
|
|
@@ -51,7 +51,7 @@ exports.ReleaseError = ReleaseError;
|
|
|
51
51
|
*
|
|
52
52
|
* @private
|
|
53
53
|
*/
|
|
54
|
-
class SessionLeakError extends
|
|
54
|
+
class SessionLeakError extends google_gax_1.GoogleError {
|
|
55
55
|
constructor(leaks) {
|
|
56
56
|
super(`${leaks.length} session leak(s) detected.`);
|
|
57
57
|
// Restore error name that was overwritten by the super constructor call.
|
|
@@ -63,7 +63,7 @@ exports.SessionLeakError = SessionLeakError;
|
|
|
63
63
|
/**
|
|
64
64
|
* Error to be thrown when the session pool is exhausted.
|
|
65
65
|
*/
|
|
66
|
-
class SessionPoolExhaustedError extends
|
|
66
|
+
class SessionPoolExhaustedError extends google_gax_1.GoogleError {
|
|
67
67
|
constructor(leaks) {
|
|
68
68
|
super("No resources available." /* Exhausted */);
|
|
69
69
|
// Restore error name that was overwritten by the super constructor call.
|
|
@@ -435,7 +435,7 @@ class SessionPool extends events_1.EventEmitter {
|
|
|
435
435
|
*/
|
|
436
436
|
async _acquire(type) {
|
|
437
437
|
if (!this.isOpen) {
|
|
438
|
-
throw new
|
|
438
|
+
throw new google_gax_1.GoogleError("Database is closed." /* Closed */);
|
|
439
439
|
}
|
|
440
440
|
// Get the stacktrace of the caller before we call any async methods, as calling an async method will break the stacktrace.
|
|
441
441
|
const frames = trace.get();
|
|
@@ -446,7 +446,7 @@ class SessionPool extends events_1.EventEmitter {
|
|
|
446
446
|
const getSession = async () => {
|
|
447
447
|
const elapsed = Date.now() - startTime;
|
|
448
448
|
if (elapsed >= timeout) {
|
|
449
|
-
throw new
|
|
449
|
+
throw new google_gax_1.GoogleError("Timeout occurred while acquiring session." /* Timeout */);
|
|
450
450
|
}
|
|
451
451
|
const session = await this._getSession(type, startTime);
|
|
452
452
|
if (this._isValidSession(session)) {
|
|
@@ -706,7 +706,7 @@ class SessionPool extends events_1.EventEmitter {
|
|
|
706
706
|
const availableEvent = type + '-available';
|
|
707
707
|
const promises = [
|
|
708
708
|
this._onClose.then(() => {
|
|
709
|
-
throw new
|
|
709
|
+
throw new google_gax_1.GoogleError("Database is closed." /* Closed */);
|
|
710
710
|
}),
|
|
711
711
|
new Promise(resolve => {
|
|
712
712
|
this.once(availableEvent, resolve);
|
package/build/src/session.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare type DeleteSessionCallback = NormalCallback<google.protobuf.IEmpt
|
|
|
51
51
|
* assumed you are going to create it.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
|
+
* ```
|
|
54
55
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
55
56
|
* const spanner = new Spanner();
|
|
56
57
|
*
|
|
@@ -75,6 +76,7 @@ export declare type DeleteSessionCallback = NormalCallback<google.protobuf.IEmpt
|
|
|
75
76
|
* // To access a previously-created session, provide a name.
|
|
76
77
|
* //-
|
|
77
78
|
* const session = database.session('session-name');
|
|
79
|
+
* ```
|
|
78
80
|
*/
|
|
79
81
|
export declare class Session extends common.GrpcServiceObject {
|
|
80
82
|
id: string;
|
|
@@ -87,12 +89,100 @@ export declare class Session extends common.GrpcServiceObject {
|
|
|
87
89
|
[k: string]: string;
|
|
88
90
|
};
|
|
89
91
|
constructor(database: Database, name?: string);
|
|
92
|
+
/**
|
|
93
|
+
* Delete a session.
|
|
94
|
+
*
|
|
95
|
+
* Wrapper around {@link v1.SpannerClient#deleteSession}.
|
|
96
|
+
*
|
|
97
|
+
* @see {@link v1.SpannerClient#deleteSession}
|
|
98
|
+
* @see [DeleteSession API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.DeleteSession)
|
|
99
|
+
*
|
|
100
|
+
* @param {object} [gaxOptions] Request configuration options,
|
|
101
|
+
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
102
|
+
* for more details.
|
|
103
|
+
* @param {DeleteSessionCallback} [callback] Callback function.
|
|
104
|
+
* @returns {Promise<DeleteSessionResponse>}
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```
|
|
108
|
+
* session.delete(function(err, apiResponse) {
|
|
109
|
+
* if (err) {
|
|
110
|
+
* // Error handling omitted.
|
|
111
|
+
* }
|
|
112
|
+
*
|
|
113
|
+
* // Session deleted successfully.
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* //-
|
|
117
|
+
* //Returns a Promise if the callback is omitted.
|
|
118
|
+
* //-
|
|
119
|
+
* session.delete().then(function(data) {
|
|
120
|
+
* const apiResponse = data[0];
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
90
124
|
delete(gaxOptions?: CallOptions): Promise<DeleteSessionResponse>;
|
|
91
125
|
delete(callback: DeleteSessionCallback): void;
|
|
92
126
|
delete(gaxOptions: CallOptions, callback: DeleteSessionCallback): void;
|
|
127
|
+
/**
|
|
128
|
+
* @typedef {array} GetSessionMetadataResponse
|
|
129
|
+
* @property {object} 0 The session's metadata.
|
|
130
|
+
* @property {object} 1 The full API response.
|
|
131
|
+
*/
|
|
132
|
+
/**
|
|
133
|
+
* @callback GetSessionMetadataCallback
|
|
134
|
+
* @param {?Error} err Request error, if any.
|
|
135
|
+
* @param {object} metadata The session's metadata.
|
|
136
|
+
* @param {object} apiResponse The full API response.
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* Get the session's metadata.
|
|
140
|
+
*
|
|
141
|
+
* Wrapper around {@link v1.SpannerClient#getSession}.
|
|
142
|
+
*
|
|
143
|
+
* @see {@link v1.SpannerClient#getSession}
|
|
144
|
+
* @see [GetSession API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.GetSession)
|
|
145
|
+
*
|
|
146
|
+
* @param {object} [gaxOptions] Request configuration options,
|
|
147
|
+
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
148
|
+
* for more details.
|
|
149
|
+
* @param {GetSessionMetadataCallback} [callback] Callback function.
|
|
150
|
+
* @returns {Promise<GetSessionMetadataResponse>}
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```
|
|
154
|
+
* session.getMetadata(function(err, metadata, apiResponse) {});
|
|
155
|
+
*
|
|
156
|
+
* //-
|
|
157
|
+
* //Returns a Promise if the callback is omitted.
|
|
158
|
+
* //-
|
|
159
|
+
* session.getMetadata().then(function(data) {
|
|
160
|
+
* const metadata = data[0];
|
|
161
|
+
* const apiResponse = data[1];
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
93
165
|
getMetadata(gaxOptions?: CallOptions): Promise<GetSessionMetadataResponse>;
|
|
94
166
|
getMetadata(callback: GetSessionMetadataCallback): void;
|
|
95
167
|
getMetadata(gaxOptions: CallOptions, callback: GetSessionMetadataCallback): void;
|
|
168
|
+
/**
|
|
169
|
+
* Ping the session with `SELECT 1` to prevent it from expiring.
|
|
170
|
+
*
|
|
171
|
+
* @param {object} [gaxOptions] Request configuration options,
|
|
172
|
+
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
173
|
+
* for more details.
|
|
174
|
+
* @param {BasicCallback} [callback] Callback function.
|
|
175
|
+
* @returns {Promise<BasicResponse>}
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```
|
|
179
|
+
* session.keepAlive(function(err) {
|
|
180
|
+
* if (err) {
|
|
181
|
+
* // An error occurred while trying to keep this session alive.
|
|
182
|
+
* }
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
96
186
|
keepAlive(gaxOptions?: CallOptions): Promise<KeepAliveResponse>;
|
|
97
187
|
keepAlive(callback: KeepAliveCallback): void;
|
|
98
188
|
keepAlive(gaxOptions: CallOptions, callback: KeepAliveCallback): void;
|
|
@@ -102,7 +192,9 @@ export declare class Session extends common.GrpcServiceObject {
|
|
|
102
192
|
* @returns {PartitionedDml}
|
|
103
193
|
*
|
|
104
194
|
* @example
|
|
195
|
+
* ```
|
|
105
196
|
* const transaction = session.partitionedDml();
|
|
197
|
+
* ```
|
|
106
198
|
*/
|
|
107
199
|
partitionedDml(): PartitionedDml;
|
|
108
200
|
/**
|
|
@@ -113,7 +205,9 @@ export declare class Session extends common.GrpcServiceObject {
|
|
|
113
205
|
* @returns {Snapshot}
|
|
114
206
|
*
|
|
115
207
|
* @example
|
|
208
|
+
* ```
|
|
116
209
|
* const snapshot = session.snapshot({strong: false});
|
|
210
|
+
* ```
|
|
117
211
|
*/
|
|
118
212
|
snapshot(options?: TimestampBounds, queryOptions?: google.spanner.v1.ExecuteSqlRequest.IQueryOptions): Snapshot;
|
|
119
213
|
/**
|
|
@@ -123,7 +217,9 @@ export declare class Session extends common.GrpcServiceObject {
|
|
|
123
217
|
* @return {Transaction}
|
|
124
218
|
*
|
|
125
219
|
* @example
|
|
220
|
+
* ```
|
|
126
221
|
* const transaction = session.transaction();
|
|
222
|
+
* ```
|
|
127
223
|
*/
|
|
128
224
|
transaction(queryOptions?: google.spanner.v1.ExecuteSqlRequest.IQueryOptions, requestOptions?: Pick<IRequestOptions, 'transactionTag'>): Transaction;
|
|
129
225
|
/**
|
|
@@ -136,9 +232,11 @@ export declare class Session extends common.GrpcServiceObject {
|
|
|
136
232
|
* @returns {string}
|
|
137
233
|
*
|
|
138
234
|
* @example
|
|
235
|
+
* ```
|
|
139
236
|
* Session.formatName_('my-database', 'my-session');
|
|
140
237
|
* // 'projects/grape-spaceship-123/instances/my-instance/' +
|
|
141
238
|
* // 'databases/my-database/sessions/my-session'
|
|
239
|
+
* ```
|
|
142
240
|
*/
|
|
143
241
|
static formatName_(databaseName: string, name: string): string;
|
|
144
242
|
}
|
package/build/src/session.js
CHANGED
|
@@ -38,6 +38,7 @@ const common_1 = require("./common");
|
|
|
38
38
|
* assumed you are going to create it.
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
|
+
* ```
|
|
41
42
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
42
43
|
* const spanner = new Spanner();
|
|
43
44
|
*
|
|
@@ -62,6 +63,7 @@ const common_1 = require("./common");
|
|
|
62
63
|
* // To access a previously-created session, provide a name.
|
|
63
64
|
* //-
|
|
64
65
|
* const session = database.session('session-name');
|
|
66
|
+
* ```
|
|
65
67
|
*/
|
|
66
68
|
class Session extends common.GrpcServiceObject {
|
|
67
69
|
constructor(database, name) {
|
|
@@ -75,6 +77,7 @@ class Session extends common.GrpcServiceObject {
|
|
|
75
77
|
* @returns {Promise<CreateSessionResponse>}
|
|
76
78
|
*
|
|
77
79
|
* @example
|
|
80
|
+
* ```
|
|
78
81
|
* session.create(function(err, session, apiResponse) {
|
|
79
82
|
* if (err) {
|
|
80
83
|
* // Error handling omitted.
|
|
@@ -93,6 +96,7 @@ class Session extends common.GrpcServiceObject {
|
|
|
93
96
|
*
|
|
94
97
|
* // Session created successfully.
|
|
95
98
|
* });
|
|
99
|
+
* ```
|
|
96
100
|
*/
|
|
97
101
|
create: true,
|
|
98
102
|
/**
|
|
@@ -112,6 +116,7 @@ class Session extends common.GrpcServiceObject {
|
|
|
112
116
|
* @returns {Promise<SessionExistsResponse>}
|
|
113
117
|
*
|
|
114
118
|
* @example
|
|
119
|
+
* ```
|
|
115
120
|
* session.exists(function(err, exists) {});
|
|
116
121
|
*
|
|
117
122
|
* //-
|
|
@@ -120,6 +125,7 @@ class Session extends common.GrpcServiceObject {
|
|
|
120
125
|
* session.exists().then(function(data) {
|
|
121
126
|
* const exists = data[0];
|
|
122
127
|
* });
|
|
128
|
+
* ```
|
|
123
129
|
*/
|
|
124
130
|
exists: true,
|
|
125
131
|
/**
|
|
@@ -149,6 +155,7 @@ class Session extends common.GrpcServiceObject {
|
|
|
149
155
|
* @returns {Promise<GetSessionResponse>}
|
|
150
156
|
*
|
|
151
157
|
* @example
|
|
158
|
+
* ```
|
|
152
159
|
* session.get(function(err, session, apiResponse) {
|
|
153
160
|
* // `session.metadata` has been populated.
|
|
154
161
|
* });
|
|
@@ -160,6 +167,7 @@ class Session extends common.GrpcServiceObject {
|
|
|
160
167
|
* const session = data[0];
|
|
161
168
|
* const apiResponse = data[0];
|
|
162
169
|
* });
|
|
170
|
+
* ```
|
|
163
171
|
*/
|
|
164
172
|
get: true,
|
|
165
173
|
};
|
|
@@ -196,36 +204,6 @@ class Session extends common.GrpcServiceObject {
|
|
|
196
204
|
this.formattedName_ = Session.formatName_(database.formattedName_, name);
|
|
197
205
|
}
|
|
198
206
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Delete a session.
|
|
201
|
-
*
|
|
202
|
-
* Wrapper around {@link v1.SpannerClient#deleteSession}.
|
|
203
|
-
*
|
|
204
|
-
* @see {@link v1.SpannerClient#deleteSession}
|
|
205
|
-
* @see [DeleteSession API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.DeleteSession)
|
|
206
|
-
*
|
|
207
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
208
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
209
|
-
* for more details.
|
|
210
|
-
* @param {DeleteSessionCallback} [callback] Callback function.
|
|
211
|
-
* @returns {Promise<DeleteSessionResponse>}
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* session.delete(function(err, apiResponse) {
|
|
215
|
-
* if (err) {
|
|
216
|
-
* // Error handling omitted.
|
|
217
|
-
* }
|
|
218
|
-
*
|
|
219
|
-
* // Session deleted successfully.
|
|
220
|
-
* });
|
|
221
|
-
*
|
|
222
|
-
* //-
|
|
223
|
-
* //Returns a Promise if the callback is omitted.
|
|
224
|
-
* //-
|
|
225
|
-
* session.delete().then(function(data) {
|
|
226
|
-
* const apiResponse = data[0];
|
|
227
|
-
* });
|
|
228
|
-
*/
|
|
229
207
|
delete(optionsOrCallback, cb) {
|
|
230
208
|
const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
|
|
231
209
|
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
|
|
@@ -240,42 +218,6 @@ class Session extends common.GrpcServiceObject {
|
|
|
240
218
|
headers: this.resourceHeader_,
|
|
241
219
|
}, callback);
|
|
242
220
|
}
|
|
243
|
-
/**
|
|
244
|
-
* @typedef {array} GetSessionMetadataResponse
|
|
245
|
-
* @property {object} 0 The session's metadata.
|
|
246
|
-
* @property {object} 1 The full API response.
|
|
247
|
-
*/
|
|
248
|
-
/**
|
|
249
|
-
* @callback GetSessionMetadataCallback
|
|
250
|
-
* @param {?Error} err Request error, if any.
|
|
251
|
-
* @param {object} metadata The session's metadata.
|
|
252
|
-
* @param {object} apiResponse The full API response.
|
|
253
|
-
*/
|
|
254
|
-
/**
|
|
255
|
-
* Get the session's metadata.
|
|
256
|
-
*
|
|
257
|
-
* Wrapper around {@link v1.SpannerClient#getSession}.
|
|
258
|
-
*
|
|
259
|
-
* @see {@link v1.SpannerClient#getSession}
|
|
260
|
-
* @see [GetSession API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.GetSession)
|
|
261
|
-
*
|
|
262
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
263
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
264
|
-
* for more details.
|
|
265
|
-
* @param {GetSessionMetadataCallback} [callback] Callback function.
|
|
266
|
-
* @returns {Promise<GetSessionMetadataResponse>}
|
|
267
|
-
*
|
|
268
|
-
* @example
|
|
269
|
-
* session.getMetadata(function(err, metadata, apiResponse) {});
|
|
270
|
-
*
|
|
271
|
-
* //-
|
|
272
|
-
* //Returns a Promise if the callback is omitted.
|
|
273
|
-
* //-
|
|
274
|
-
* session.getMetadata().then(function(data) {
|
|
275
|
-
* const metadata = data[0];
|
|
276
|
-
* const apiResponse = data[1];
|
|
277
|
-
* });
|
|
278
|
-
*/
|
|
279
221
|
getMetadata(optionsOrCallback, cb) {
|
|
280
222
|
const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
|
|
281
223
|
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
|
|
@@ -295,22 +237,6 @@ class Session extends common.GrpcServiceObject {
|
|
|
295
237
|
callback(err, resp);
|
|
296
238
|
});
|
|
297
239
|
}
|
|
298
|
-
/**
|
|
299
|
-
* Ping the session with `SELECT 1` to prevent it from expiring.
|
|
300
|
-
*
|
|
301
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
302
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
303
|
-
* for more details.
|
|
304
|
-
* @param {BasicCallback} [callback] Callback function.
|
|
305
|
-
* @returns {Promise<BasicResponse>}
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
* session.keepAlive(function(err) {
|
|
309
|
-
* if (err) {
|
|
310
|
-
* // An error occurred while trying to keep this session alive.
|
|
311
|
-
* }
|
|
312
|
-
* });
|
|
313
|
-
*/
|
|
314
240
|
keepAlive(optionsOrCallback, cb) {
|
|
315
241
|
const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
|
|
316
242
|
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
|
|
@@ -332,7 +258,9 @@ class Session extends common.GrpcServiceObject {
|
|
|
332
258
|
* @returns {PartitionedDml}
|
|
333
259
|
*
|
|
334
260
|
* @example
|
|
261
|
+
* ```
|
|
335
262
|
* const transaction = session.partitionedDml();
|
|
263
|
+
* ```
|
|
336
264
|
*/
|
|
337
265
|
partitionedDml() {
|
|
338
266
|
return new transaction_1.PartitionedDml(this);
|
|
@@ -345,7 +273,9 @@ class Session extends common.GrpcServiceObject {
|
|
|
345
273
|
* @returns {Snapshot}
|
|
346
274
|
*
|
|
347
275
|
* @example
|
|
276
|
+
* ```
|
|
348
277
|
* const snapshot = session.snapshot({strong: false});
|
|
278
|
+
* ```
|
|
349
279
|
*/
|
|
350
280
|
snapshot(options, queryOptions) {
|
|
351
281
|
return new transaction_1.Snapshot(this, options, queryOptions);
|
|
@@ -357,7 +287,9 @@ class Session extends common.GrpcServiceObject {
|
|
|
357
287
|
* @return {Transaction}
|
|
358
288
|
*
|
|
359
289
|
* @example
|
|
290
|
+
* ```
|
|
360
291
|
* const transaction = session.transaction();
|
|
292
|
+
* ```
|
|
361
293
|
*/
|
|
362
294
|
transaction(queryOptions, requestOptions) {
|
|
363
295
|
return new transaction_1.Transaction(this, undefined, queryOptions, requestOptions);
|
|
@@ -372,9 +304,11 @@ class Session extends common.GrpcServiceObject {
|
|
|
372
304
|
* @returns {string}
|
|
373
305
|
*
|
|
374
306
|
* @example
|
|
307
|
+
* ```
|
|
375
308
|
* Session.formatName_('my-database', 'my-session');
|
|
376
309
|
* // 'projects/grape-spaceship-123/instances/my-instance/' +
|
|
377
310
|
* // 'databases/my-database/sessions/my-session'
|
|
311
|
+
* ```
|
|
378
312
|
*/
|
|
379
313
|
static formatName_(databaseName, name) {
|
|
380
314
|
if (name.indexOf('/') > -1) {
|