@google-cloud/firestore-api 0.1.0 → 0.4.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/build/protos/protos.d.ts +1620 -7935
- package/build/protos/protos.js +1 -1
- package/build/protos/protos.json +1 -1
- package/build/src/index.d.ts +7 -6
- package/build/src/index.js +5 -5
- package/build/src/index.js.map +1 -1
- package/build/src/v1/gapic_metadata.json +72 -248
- package/build/src/v1/index.js +2 -2
- package/build/src/v1/index.js.map +1 -1
- package/package.json +43 -8
- package/build/protos/google/firestore/v1beta1/common.proto +0 -82
- package/build/protos/google/firestore/v1beta1/document.proto +0 -149
- package/build/protos/google/firestore/v1beta1/firestore.proto +0 -900
- package/build/protos/google/firestore/v1beta1/query.proto +0 -300
- package/build/protos/google/firestore/v1beta1/undeliverable_first_gen_event.proto +0 -75
- package/build/protos/google/firestore/v1beta1/write.proto +0 -258
- package/build/src/v1beta1/firestore_client.d.ts +0 -930
- package/build/src/v1beta1/firestore_client.js +0 -1310
- package/build/src/v1beta1/firestore_client.js.map +0 -1
- package/build/src/v1beta1/firestore_client_config.json +0 -99
- package/build/src/v1beta1/firestore_proto_list.json +0 -8
- package/build/src/v1beta1/gapic_metadata.json +0 -165
- package/build/src/v1beta1/index.d.ts +0 -1
- package/build/src/v1beta1/index.js +0 -23
- package/build/src/v1beta1/index.js.map +0 -1
|
@@ -1,1310 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2026 Google LLC
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
15
|
-
//
|
|
16
|
-
// ** This file is automatically generated by gapic-generator-typescript. **
|
|
17
|
-
// ** https://github.com/googleapis/gapic-generator-typescript **
|
|
18
|
-
// ** All changes to this file may be overwritten. **
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.FirestoreClient = void 0;
|
|
21
|
-
const stream_1 = require("stream");
|
|
22
|
-
const jsonProtos = require("../../protos/protos.json");
|
|
23
|
-
const google_gax_1 = require("google-gax");
|
|
24
|
-
/**
|
|
25
|
-
* Client JSON configuration object, loaded from
|
|
26
|
-
* `src/v1beta1/firestore_client_config.json`.
|
|
27
|
-
* This file defines retry strategy and timeouts for all API methods in this library.
|
|
28
|
-
*/
|
|
29
|
-
const gapicConfig = require("./firestore_client_config.json");
|
|
30
|
-
const version = require('../../../package.json').version;
|
|
31
|
-
/**
|
|
32
|
-
* The Cloud Firestore service.
|
|
33
|
-
*
|
|
34
|
-
* Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
|
|
35
|
-
* document database that simplifies storing, syncing, and querying data for
|
|
36
|
-
* your mobile, web, and IoT apps at global scale. Its client libraries provide
|
|
37
|
-
* live synchronization and offline support, while its security features and
|
|
38
|
-
* integrations with Firebase and Google Cloud Platform (GCP) accelerate
|
|
39
|
-
* building truly serverless apps.
|
|
40
|
-
* @class
|
|
41
|
-
* @memberof v1beta1
|
|
42
|
-
*/
|
|
43
|
-
class FirestoreClient {
|
|
44
|
-
_terminated = false;
|
|
45
|
-
_opts;
|
|
46
|
-
_providedCustomServicePath;
|
|
47
|
-
_gaxModule;
|
|
48
|
-
_gaxGrpc;
|
|
49
|
-
_protos;
|
|
50
|
-
_defaults;
|
|
51
|
-
_universeDomain;
|
|
52
|
-
_servicePath;
|
|
53
|
-
_log = google_gax_1.loggingUtils.log('firestore-api');
|
|
54
|
-
auth;
|
|
55
|
-
descriptors = {
|
|
56
|
-
page: {},
|
|
57
|
-
stream: {},
|
|
58
|
-
longrunning: {},
|
|
59
|
-
batching: {},
|
|
60
|
-
};
|
|
61
|
-
warn;
|
|
62
|
-
innerApiCalls;
|
|
63
|
-
firestoreStub;
|
|
64
|
-
/**
|
|
65
|
-
* Construct an instance of FirestoreClient.
|
|
66
|
-
*
|
|
67
|
-
* @param {object} [options] - The configuration object.
|
|
68
|
-
* The options accepted by the constructor are described in detail
|
|
69
|
-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
|
|
70
|
-
* The common options are:
|
|
71
|
-
* @param {object} [options.credentials] - Credentials object.
|
|
72
|
-
* @param {string} [options.credentials.client_email]
|
|
73
|
-
* @param {string} [options.credentials.private_key]
|
|
74
|
-
* @param {string} [options.email] - Account email address. Required when
|
|
75
|
-
* using a .pem or .p12 keyFilename.
|
|
76
|
-
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
|
|
77
|
-
* .p12 key downloaded from the Google Developers Console. If you provide
|
|
78
|
-
* a path to a JSON file, the projectId option below is not necessary.
|
|
79
|
-
* NOTE: .pem and .p12 require you to specify options.email as well.
|
|
80
|
-
* @param {number} [options.port] - The port on which to connect to
|
|
81
|
-
* the remote host.
|
|
82
|
-
* @param {string} [options.projectId] - The project ID from the Google
|
|
83
|
-
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
|
|
84
|
-
* the environment variable GCLOUD_PROJECT for your project ID. If your
|
|
85
|
-
* app is running in an environment which supports
|
|
86
|
-
* {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
|
|
87
|
-
* your project ID will be detected automatically.
|
|
88
|
-
* @param {string} [options.apiEndpoint] - The domain name of the
|
|
89
|
-
* API remote host.
|
|
90
|
-
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
|
|
91
|
-
* Follows the structure of {@link gapicConfig}.
|
|
92
|
-
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
|
|
93
|
-
* For more information, please check the
|
|
94
|
-
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
|
|
95
|
-
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
|
|
96
|
-
* need to avoid loading the default gRPC version and want to use the fallback
|
|
97
|
-
* HTTP implementation. Load only fallback version and pass it to the constructor:
|
|
98
|
-
* ```
|
|
99
|
-
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
|
|
100
|
-
* const client = new FirestoreClient({fallback: true}, gax);
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
constructor(opts, gaxInstance) {
|
|
104
|
-
// Ensure that options include all the required fields.
|
|
105
|
-
const staticMembers = this.constructor;
|
|
106
|
-
if (opts?.universe_domain &&
|
|
107
|
-
opts?.universeDomain &&
|
|
108
|
-
opts?.universe_domain !== opts?.universeDomain) {
|
|
109
|
-
throw new Error('Please set either universe_domain or universeDomain, but not both.');
|
|
110
|
-
}
|
|
111
|
-
const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
|
|
112
|
-
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
|
|
113
|
-
: undefined;
|
|
114
|
-
this._universeDomain =
|
|
115
|
-
opts?.universeDomain ??
|
|
116
|
-
opts?.universe_domain ??
|
|
117
|
-
universeDomainEnvVar ??
|
|
118
|
-
'googleapis.com';
|
|
119
|
-
this._servicePath = 'firestore.' + this._universeDomain;
|
|
120
|
-
const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
|
|
121
|
-
this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
|
|
122
|
-
const port = opts?.port || staticMembers.port;
|
|
123
|
-
const clientConfig = opts?.clientConfig ?? {};
|
|
124
|
-
const fallback = opts?.fallback ??
|
|
125
|
-
(typeof window !== 'undefined' && typeof window?.fetch === 'function');
|
|
126
|
-
opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
|
|
127
|
-
// Request numeric enum values if REST transport is used.
|
|
128
|
-
opts.numericEnums = true;
|
|
129
|
-
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
|
|
130
|
-
if (servicePath !== this._servicePath && !('scopes' in opts)) {
|
|
131
|
-
opts['scopes'] = staticMembers.scopes;
|
|
132
|
-
}
|
|
133
|
-
// Load google-gax module synchronously if needed
|
|
134
|
-
if (!gaxInstance) {
|
|
135
|
-
gaxInstance = require('google-gax');
|
|
136
|
-
}
|
|
137
|
-
// Choose either gRPC or proto-over-HTTP implementation of google-gax.
|
|
138
|
-
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
|
|
139
|
-
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
|
|
140
|
-
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
|
|
141
|
-
// Save options to use in initialize() method.
|
|
142
|
-
this._opts = opts;
|
|
143
|
-
// Save the auth object to the client, for use by other methods.
|
|
144
|
-
this.auth = this._gaxGrpc.auth;
|
|
145
|
-
// Set useJWTAccessWithScope on the auth object.
|
|
146
|
-
this.auth.useJWTAccessWithScope = true;
|
|
147
|
-
// Set defaultServicePath on the auth object.
|
|
148
|
-
this.auth.defaultServicePath = this._servicePath;
|
|
149
|
-
// Set the default scopes in auth client if needed.
|
|
150
|
-
if (servicePath === this._servicePath) {
|
|
151
|
-
this.auth.defaultScopes = staticMembers.scopes;
|
|
152
|
-
}
|
|
153
|
-
// Determine the client header string.
|
|
154
|
-
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
|
|
155
|
-
if (typeof process === 'object' && 'versions' in process) {
|
|
156
|
-
clientHeader.push(`gl-node/${process.versions.node}`);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
clientHeader.push(`gl-web/${this._gaxModule.version}`);
|
|
160
|
-
}
|
|
161
|
-
if (!opts.fallback) {
|
|
162
|
-
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
|
|
166
|
-
}
|
|
167
|
-
if (opts.libName && opts.libVersion) {
|
|
168
|
-
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
|
|
169
|
-
}
|
|
170
|
-
// Load the applicable protos.
|
|
171
|
-
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
|
|
172
|
-
// Some of the methods on this service return "paged" results,
|
|
173
|
-
// (e.g. 50 results at a time, with tokens to get subsequent
|
|
174
|
-
// pages). Denote the keys used for pagination and results.
|
|
175
|
-
this.descriptors.page = {
|
|
176
|
-
listDocuments: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'),
|
|
177
|
-
partitionQuery: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'partitions'),
|
|
178
|
-
listCollectionIds: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds'),
|
|
179
|
-
};
|
|
180
|
-
// Some of the methods on this service provide streaming responses.
|
|
181
|
-
// Provide descriptors for these.
|
|
182
|
-
this.descriptors.stream = {
|
|
183
|
-
batchGetDocuments: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
184
|
-
runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
185
|
-
write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
186
|
-
listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
187
|
-
};
|
|
188
|
-
// Put together the default options sent with requests.
|
|
189
|
-
this._defaults = this._gaxGrpc.constructSettings('google.firestore.v1beta1.Firestore', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
|
|
190
|
-
// Set up a dictionary of "inner API calls"; the core implementation
|
|
191
|
-
// of calling the API is handled in `google-gax`, with this code
|
|
192
|
-
// merely providing the destination and request information.
|
|
193
|
-
this.innerApiCalls = {};
|
|
194
|
-
// Add a warn function to the client constructor so it can be easily tested.
|
|
195
|
-
this.warn = this._gaxModule.warn;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Initialize the client.
|
|
199
|
-
* Performs asynchronous operations (such as authentication) and prepares the client.
|
|
200
|
-
* This function will be called automatically when any class method is called for the
|
|
201
|
-
* first time, but if you need to initialize it before calling an actual method,
|
|
202
|
-
* feel free to call initialize() directly.
|
|
203
|
-
*
|
|
204
|
-
* You can await on this method if you want to make sure the client is initialized.
|
|
205
|
-
*
|
|
206
|
-
* @returns {Promise} A promise that resolves to an authenticated service stub.
|
|
207
|
-
*/
|
|
208
|
-
initialize() {
|
|
209
|
-
// If the client stub promise is already initialized, return immediately.
|
|
210
|
-
if (this.firestoreStub) {
|
|
211
|
-
return this.firestoreStub;
|
|
212
|
-
}
|
|
213
|
-
// Put together the "service stub" for
|
|
214
|
-
// google.firestore.v1beta1.Firestore.
|
|
215
|
-
this.firestoreStub = this._gaxGrpc.createStub(this._opts.fallback
|
|
216
|
-
? this._protos.lookupService('google.firestore.v1beta1.Firestore')
|
|
217
|
-
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
|
-
this._protos.google.firestore.v1beta1.Firestore, this._opts, this._providedCustomServicePath);
|
|
219
|
-
// Iterate over each of the methods that the service provides
|
|
220
|
-
// and create an API call method for each.
|
|
221
|
-
const firestoreStubMethods = [
|
|
222
|
-
'getDocument',
|
|
223
|
-
'listDocuments',
|
|
224
|
-
'updateDocument',
|
|
225
|
-
'deleteDocument',
|
|
226
|
-
'batchGetDocuments',
|
|
227
|
-
'beginTransaction',
|
|
228
|
-
'commit',
|
|
229
|
-
'rollback',
|
|
230
|
-
'runQuery',
|
|
231
|
-
'partitionQuery',
|
|
232
|
-
'write',
|
|
233
|
-
'listen',
|
|
234
|
-
'listCollectionIds',
|
|
235
|
-
'batchWrite',
|
|
236
|
-
'createDocument',
|
|
237
|
-
];
|
|
238
|
-
for (const methodName of firestoreStubMethods) {
|
|
239
|
-
const callPromise = this.firestoreStub.then((stub) => (...args) => {
|
|
240
|
-
if (this._terminated) {
|
|
241
|
-
if (methodName in this.descriptors.stream) {
|
|
242
|
-
const stream = new stream_1.PassThrough({ objectMode: true });
|
|
243
|
-
setImmediate(() => {
|
|
244
|
-
stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.'));
|
|
245
|
-
});
|
|
246
|
-
return stream;
|
|
247
|
-
}
|
|
248
|
-
return Promise.reject('The client has already been closed.');
|
|
249
|
-
}
|
|
250
|
-
const func = stub[methodName];
|
|
251
|
-
return func.apply(stub, args);
|
|
252
|
-
}, (err) => () => {
|
|
253
|
-
throw err;
|
|
254
|
-
});
|
|
255
|
-
const descriptor = this.descriptors.page[methodName] ||
|
|
256
|
-
this.descriptors.stream[methodName] ||
|
|
257
|
-
undefined;
|
|
258
|
-
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
|
|
259
|
-
this.innerApiCalls[methodName] = apiCall;
|
|
260
|
-
}
|
|
261
|
-
return this.firestoreStub;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* The DNS address for this API service.
|
|
265
|
-
* @deprecated Use the apiEndpoint method of the client instance.
|
|
266
|
-
* @returns {string} The DNS address for this service.
|
|
267
|
-
*/
|
|
268
|
-
static get servicePath() {
|
|
269
|
-
if (typeof process === 'object' &&
|
|
270
|
-
typeof process.emitWarning === 'function') {
|
|
271
|
-
process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
|
|
272
|
-
}
|
|
273
|
-
return 'firestore.googleapis.com';
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* The DNS address for this API service - same as servicePath.
|
|
277
|
-
* @deprecated Use the apiEndpoint method of the client instance.
|
|
278
|
-
* @returns {string} The DNS address for this service.
|
|
279
|
-
*/
|
|
280
|
-
static get apiEndpoint() {
|
|
281
|
-
if (typeof process === 'object' &&
|
|
282
|
-
typeof process.emitWarning === 'function') {
|
|
283
|
-
process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
|
|
284
|
-
}
|
|
285
|
-
return 'firestore.googleapis.com';
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* The DNS address for this API service.
|
|
289
|
-
* @returns {string} The DNS address for this service.
|
|
290
|
-
*/
|
|
291
|
-
get apiEndpoint() {
|
|
292
|
-
return this._servicePath;
|
|
293
|
-
}
|
|
294
|
-
get universeDomain() {
|
|
295
|
-
return this._universeDomain;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* The port for this API service.
|
|
299
|
-
* @returns {number} The default port for this service.
|
|
300
|
-
*/
|
|
301
|
-
static get port() {
|
|
302
|
-
return 443;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* The scopes needed to make gRPC calls for every method defined
|
|
306
|
-
* in this service.
|
|
307
|
-
* @returns {string[]} List of default scopes.
|
|
308
|
-
*/
|
|
309
|
-
static get scopes() {
|
|
310
|
-
return [
|
|
311
|
-
'https://www.googleapis.com/auth/cloud-platform',
|
|
312
|
-
'https://www.googleapis.com/auth/datastore',
|
|
313
|
-
];
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Return the project ID used by this class.
|
|
317
|
-
* @returns {Promise} A promise that resolves to string containing the project ID.
|
|
318
|
-
*/
|
|
319
|
-
getProjectId(callback) {
|
|
320
|
-
if (callback) {
|
|
321
|
-
this.auth.getProjectId(callback);
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
return this.auth.getProjectId();
|
|
325
|
-
}
|
|
326
|
-
getDocument(request, optionsOrCallback, callback) {
|
|
327
|
-
request = request || {};
|
|
328
|
-
let options;
|
|
329
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
330
|
-
callback = optionsOrCallback;
|
|
331
|
-
options = {};
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
options = optionsOrCallback;
|
|
335
|
-
}
|
|
336
|
-
options = options || {};
|
|
337
|
-
options.otherArgs = options.otherArgs || {};
|
|
338
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
339
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
340
|
-
this._gaxModule.routingHeader.fromParams({
|
|
341
|
-
name: request.name ?? '',
|
|
342
|
-
});
|
|
343
|
-
this.initialize().catch((err) => {
|
|
344
|
-
throw err;
|
|
345
|
-
});
|
|
346
|
-
this._log.info('getDocument request %j', request);
|
|
347
|
-
const wrappedCallback = callback
|
|
348
|
-
? (error, response, options, rawResponse) => {
|
|
349
|
-
this._log.info('getDocument response %j', response);
|
|
350
|
-
callback(error, response, options, rawResponse); // We verified callback above.
|
|
351
|
-
}
|
|
352
|
-
: undefined;
|
|
353
|
-
return this.innerApiCalls
|
|
354
|
-
.getDocument(request, options, wrappedCallback)
|
|
355
|
-
?.then(([response, options, rawResponse]) => {
|
|
356
|
-
this._log.info('getDocument response %j', response);
|
|
357
|
-
return [response, options, rawResponse];
|
|
358
|
-
})
|
|
359
|
-
.catch((error) => {
|
|
360
|
-
if (error &&
|
|
361
|
-
'statusDetails' in error &&
|
|
362
|
-
error.statusDetails instanceof Array) {
|
|
363
|
-
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
364
|
-
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
365
|
-
}
|
|
366
|
-
throw error;
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
updateDocument(request, optionsOrCallback, callback) {
|
|
370
|
-
request = request || {};
|
|
371
|
-
let options;
|
|
372
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
373
|
-
callback = optionsOrCallback;
|
|
374
|
-
options = {};
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
options = optionsOrCallback;
|
|
378
|
-
}
|
|
379
|
-
options = options || {};
|
|
380
|
-
options.otherArgs = options.otherArgs || {};
|
|
381
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
382
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
383
|
-
this._gaxModule.routingHeader.fromParams({
|
|
384
|
-
'document.name': request.document.name ?? '',
|
|
385
|
-
});
|
|
386
|
-
this.initialize().catch((err) => {
|
|
387
|
-
throw err;
|
|
388
|
-
});
|
|
389
|
-
this._log.info('updateDocument request %j', request);
|
|
390
|
-
const wrappedCallback = callback
|
|
391
|
-
? (error, response, options, rawResponse) => {
|
|
392
|
-
this._log.info('updateDocument response %j', response);
|
|
393
|
-
callback(error, response, options, rawResponse); // We verified callback above.
|
|
394
|
-
}
|
|
395
|
-
: undefined;
|
|
396
|
-
return this.innerApiCalls
|
|
397
|
-
.updateDocument(request, options, wrappedCallback)
|
|
398
|
-
?.then(([response, options, rawResponse]) => {
|
|
399
|
-
this._log.info('updateDocument response %j', response);
|
|
400
|
-
return [response, options, rawResponse];
|
|
401
|
-
})
|
|
402
|
-
.catch((error) => {
|
|
403
|
-
if (error &&
|
|
404
|
-
'statusDetails' in error &&
|
|
405
|
-
error.statusDetails instanceof Array) {
|
|
406
|
-
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
407
|
-
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
408
|
-
}
|
|
409
|
-
throw error;
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
deleteDocument(request, optionsOrCallback, callback) {
|
|
413
|
-
request = request || {};
|
|
414
|
-
let options;
|
|
415
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
416
|
-
callback = optionsOrCallback;
|
|
417
|
-
options = {};
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
options = optionsOrCallback;
|
|
421
|
-
}
|
|
422
|
-
options = options || {};
|
|
423
|
-
options.otherArgs = options.otherArgs || {};
|
|
424
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
425
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
426
|
-
this._gaxModule.routingHeader.fromParams({
|
|
427
|
-
name: request.name ?? '',
|
|
428
|
-
});
|
|
429
|
-
this.initialize().catch((err) => {
|
|
430
|
-
throw err;
|
|
431
|
-
});
|
|
432
|
-
this._log.info('deleteDocument request %j', request);
|
|
433
|
-
const wrappedCallback = callback
|
|
434
|
-
? (error, response, options, rawResponse) => {
|
|
435
|
-
this._log.info('deleteDocument response %j', response);
|
|
436
|
-
callback(error, response, options, rawResponse); // We verified callback above.
|
|
437
|
-
}
|
|
438
|
-
: undefined;
|
|
439
|
-
return this.innerApiCalls
|
|
440
|
-
.deleteDocument(request, options, wrappedCallback)
|
|
441
|
-
?.then(([response, options, rawResponse]) => {
|
|
442
|
-
this._log.info('deleteDocument response %j', response);
|
|
443
|
-
return [response, options, rawResponse];
|
|
444
|
-
})
|
|
445
|
-
.catch((error) => {
|
|
446
|
-
if (error &&
|
|
447
|
-
'statusDetails' in error &&
|
|
448
|
-
error.statusDetails instanceof Array) {
|
|
449
|
-
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
450
|
-
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
451
|
-
}
|
|
452
|
-
throw error;
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
beginTransaction(request, optionsOrCallback, callback) {
|
|
456
|
-
request = request || {};
|
|
457
|
-
let options;
|
|
458
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
459
|
-
callback = optionsOrCallback;
|
|
460
|
-
options = {};
|
|
461
|
-
}
|
|
462
|
-
else {
|
|
463
|
-
options = optionsOrCallback;
|
|
464
|
-
}
|
|
465
|
-
options = options || {};
|
|
466
|
-
options.otherArgs = options.otherArgs || {};
|
|
467
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
468
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
469
|
-
this._gaxModule.routingHeader.fromParams({
|
|
470
|
-
database: request.database ?? '',
|
|
471
|
-
});
|
|
472
|
-
this.initialize().catch((err) => {
|
|
473
|
-
throw err;
|
|
474
|
-
});
|
|
475
|
-
this._log.info('beginTransaction request %j', request);
|
|
476
|
-
const wrappedCallback = callback
|
|
477
|
-
? (error, response, options, rawResponse) => {
|
|
478
|
-
this._log.info('beginTransaction response %j', response);
|
|
479
|
-
callback(error, response, options, rawResponse); // We verified callback above.
|
|
480
|
-
}
|
|
481
|
-
: undefined;
|
|
482
|
-
return this.innerApiCalls
|
|
483
|
-
.beginTransaction(request, options, wrappedCallback)
|
|
484
|
-
?.then(([response, options, rawResponse]) => {
|
|
485
|
-
this._log.info('beginTransaction response %j', response);
|
|
486
|
-
return [response, options, rawResponse];
|
|
487
|
-
})
|
|
488
|
-
.catch((error) => {
|
|
489
|
-
if (error &&
|
|
490
|
-
'statusDetails' in error &&
|
|
491
|
-
error.statusDetails instanceof Array) {
|
|
492
|
-
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
493
|
-
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
494
|
-
}
|
|
495
|
-
throw error;
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
commit(request, optionsOrCallback, callback) {
|
|
499
|
-
request = request || {};
|
|
500
|
-
let options;
|
|
501
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
502
|
-
callback = optionsOrCallback;
|
|
503
|
-
options = {};
|
|
504
|
-
}
|
|
505
|
-
else {
|
|
506
|
-
options = optionsOrCallback;
|
|
507
|
-
}
|
|
508
|
-
options = options || {};
|
|
509
|
-
options.otherArgs = options.otherArgs || {};
|
|
510
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
511
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
512
|
-
this._gaxModule.routingHeader.fromParams({
|
|
513
|
-
database: request.database ?? '',
|
|
514
|
-
});
|
|
515
|
-
this.initialize().catch((err) => {
|
|
516
|
-
throw err;
|
|
517
|
-
});
|
|
518
|
-
this._log.info('commit request %j', request);
|
|
519
|
-
const wrappedCallback = callback
|
|
520
|
-
? (error, response, options, rawResponse) => {
|
|
521
|
-
this._log.info('commit response %j', response);
|
|
522
|
-
callback(error, response, options, rawResponse); // We verified callback above.
|
|
523
|
-
}
|
|
524
|
-
: undefined;
|
|
525
|
-
return this.innerApiCalls
|
|
526
|
-
.commit(request, options, wrappedCallback)
|
|
527
|
-
?.then(([response, options, rawResponse]) => {
|
|
528
|
-
this._log.info('commit response %j', response);
|
|
529
|
-
return [response, options, rawResponse];
|
|
530
|
-
})
|
|
531
|
-
.catch((error) => {
|
|
532
|
-
if (error &&
|
|
533
|
-
'statusDetails' in error &&
|
|
534
|
-
error.statusDetails instanceof Array) {
|
|
535
|
-
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
536
|
-
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
537
|
-
}
|
|
538
|
-
throw error;
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
rollback(request, optionsOrCallback, callback) {
|
|
542
|
-
request = request || {};
|
|
543
|
-
let options;
|
|
544
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
545
|
-
callback = optionsOrCallback;
|
|
546
|
-
options = {};
|
|
547
|
-
}
|
|
548
|
-
else {
|
|
549
|
-
options = optionsOrCallback;
|
|
550
|
-
}
|
|
551
|
-
options = options || {};
|
|
552
|
-
options.otherArgs = options.otherArgs || {};
|
|
553
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
554
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
555
|
-
this._gaxModule.routingHeader.fromParams({
|
|
556
|
-
database: request.database ?? '',
|
|
557
|
-
});
|
|
558
|
-
this.initialize().catch((err) => {
|
|
559
|
-
throw err;
|
|
560
|
-
});
|
|
561
|
-
this._log.info('rollback request %j', request);
|
|
562
|
-
const wrappedCallback = callback
|
|
563
|
-
? (error, response, options, rawResponse) => {
|
|
564
|
-
this._log.info('rollback response %j', response);
|
|
565
|
-
callback(error, response, options, rawResponse); // We verified callback above.
|
|
566
|
-
}
|
|
567
|
-
: undefined;
|
|
568
|
-
return this.innerApiCalls
|
|
569
|
-
.rollback(request, options, wrappedCallback)
|
|
570
|
-
?.then(([response, options, rawResponse]) => {
|
|
571
|
-
this._log.info('rollback response %j', response);
|
|
572
|
-
return [response, options, rawResponse];
|
|
573
|
-
})
|
|
574
|
-
.catch((error) => {
|
|
575
|
-
if (error &&
|
|
576
|
-
'statusDetails' in error &&
|
|
577
|
-
error.statusDetails instanceof Array) {
|
|
578
|
-
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
579
|
-
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
580
|
-
}
|
|
581
|
-
throw error;
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
batchWrite(request, optionsOrCallback, callback) {
|
|
585
|
-
request = request || {};
|
|
586
|
-
let options;
|
|
587
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
588
|
-
callback = optionsOrCallback;
|
|
589
|
-
options = {};
|
|
590
|
-
}
|
|
591
|
-
else {
|
|
592
|
-
options = optionsOrCallback;
|
|
593
|
-
}
|
|
594
|
-
options = options || {};
|
|
595
|
-
options.otherArgs = options.otherArgs || {};
|
|
596
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
597
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
598
|
-
this._gaxModule.routingHeader.fromParams({
|
|
599
|
-
database: request.database ?? '',
|
|
600
|
-
});
|
|
601
|
-
this.initialize().catch((err) => {
|
|
602
|
-
throw err;
|
|
603
|
-
});
|
|
604
|
-
this._log.info('batchWrite request %j', request);
|
|
605
|
-
const wrappedCallback = callback
|
|
606
|
-
? (error, response, options, rawResponse) => {
|
|
607
|
-
this._log.info('batchWrite response %j', response);
|
|
608
|
-
callback(error, response, options, rawResponse); // We verified callback above.
|
|
609
|
-
}
|
|
610
|
-
: undefined;
|
|
611
|
-
return this.innerApiCalls
|
|
612
|
-
.batchWrite(request, options, wrappedCallback)
|
|
613
|
-
?.then(([response, options, rawResponse]) => {
|
|
614
|
-
this._log.info('batchWrite response %j', response);
|
|
615
|
-
return [response, options, rawResponse];
|
|
616
|
-
})
|
|
617
|
-
.catch((error) => {
|
|
618
|
-
if (error &&
|
|
619
|
-
'statusDetails' in error &&
|
|
620
|
-
error.statusDetails instanceof Array) {
|
|
621
|
-
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
622
|
-
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
623
|
-
}
|
|
624
|
-
throw error;
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
createDocument(request, optionsOrCallback, callback) {
|
|
628
|
-
request = request || {};
|
|
629
|
-
let options;
|
|
630
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
631
|
-
callback = optionsOrCallback;
|
|
632
|
-
options = {};
|
|
633
|
-
}
|
|
634
|
-
else {
|
|
635
|
-
options = optionsOrCallback;
|
|
636
|
-
}
|
|
637
|
-
options = options || {};
|
|
638
|
-
options.otherArgs = options.otherArgs || {};
|
|
639
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
640
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
641
|
-
this._gaxModule.routingHeader.fromParams({
|
|
642
|
-
parent: request.parent ?? '',
|
|
643
|
-
collection_id: request.collectionId?.toString() ?? '',
|
|
644
|
-
});
|
|
645
|
-
this.initialize().catch((err) => {
|
|
646
|
-
throw err;
|
|
647
|
-
});
|
|
648
|
-
this._log.info('createDocument request %j', request);
|
|
649
|
-
const wrappedCallback = callback
|
|
650
|
-
? (error, response, options, rawResponse) => {
|
|
651
|
-
this._log.info('createDocument response %j', response);
|
|
652
|
-
callback(error, response, options, rawResponse); // We verified callback above.
|
|
653
|
-
}
|
|
654
|
-
: undefined;
|
|
655
|
-
return this.innerApiCalls
|
|
656
|
-
.createDocument(request, options, wrappedCallback)
|
|
657
|
-
?.then(([response, options, rawResponse]) => {
|
|
658
|
-
this._log.info('createDocument response %j', response);
|
|
659
|
-
return [response, options, rawResponse];
|
|
660
|
-
})
|
|
661
|
-
.catch((error) => {
|
|
662
|
-
if (error &&
|
|
663
|
-
'statusDetails' in error &&
|
|
664
|
-
error.statusDetails instanceof Array) {
|
|
665
|
-
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
666
|
-
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
667
|
-
}
|
|
668
|
-
throw error;
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* Gets multiple documents.
|
|
673
|
-
*
|
|
674
|
-
* Documents returned by this method are not guaranteed to be returned in the
|
|
675
|
-
* same order that they were requested.
|
|
676
|
-
*
|
|
677
|
-
* @param {Object} request
|
|
678
|
-
* The request object that will be sent.
|
|
679
|
-
* @param {string} request.database
|
|
680
|
-
* Required. The database name. In the format:
|
|
681
|
-
* `projects/{project_id}/databases/{database_id}`.
|
|
682
|
-
* @param {string[]} request.documents
|
|
683
|
-
* The names of the documents to retrieve. In the format:
|
|
684
|
-
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
|
685
|
-
* The request will fail if any of the document is not a child resource of the
|
|
686
|
-
* given `database`. Duplicate names will be elided.
|
|
687
|
-
* @param {google.firestore.v1beta1.DocumentMask} request.mask
|
|
688
|
-
* The fields to return. If not set, returns all fields.
|
|
689
|
-
*
|
|
690
|
-
* If a document has a field that is not present in this mask, that field will
|
|
691
|
-
* not be returned in the response.
|
|
692
|
-
* @param {Buffer} request.transaction
|
|
693
|
-
* Reads documents in a transaction.
|
|
694
|
-
* @param {google.firestore.v1beta1.TransactionOptions} request.newTransaction
|
|
695
|
-
* Starts a new transaction and reads the documents.
|
|
696
|
-
* Defaults to a read-only transaction.
|
|
697
|
-
* The new transaction ID will be returned as the first response in the
|
|
698
|
-
* stream.
|
|
699
|
-
* @param {google.protobuf.Timestamp} request.readTime
|
|
700
|
-
* Reads documents as they were at the given time.
|
|
701
|
-
* This may not be older than 270 seconds.
|
|
702
|
-
* @param {object} [options]
|
|
703
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
704
|
-
* @returns {Stream}
|
|
705
|
-
* An object stream which emits {@link protos.google.firestore.v1beta1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event.
|
|
706
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
707
|
-
* for more details and examples.
|
|
708
|
-
* @example <caption>include:samples/generated/v1beta1/firestore.batch_get_documents.js</caption>
|
|
709
|
-
* region_tag:firestore_v1beta1_generated_Firestore_BatchGetDocuments_async
|
|
710
|
-
*/
|
|
711
|
-
batchGetDocuments(request, options) {
|
|
712
|
-
request = request || {};
|
|
713
|
-
options = options || {};
|
|
714
|
-
options.otherArgs = options.otherArgs || {};
|
|
715
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
716
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
717
|
-
this._gaxModule.routingHeader.fromParams({
|
|
718
|
-
database: request.database ?? '',
|
|
719
|
-
});
|
|
720
|
-
this.initialize().catch((err) => {
|
|
721
|
-
throw err;
|
|
722
|
-
});
|
|
723
|
-
this._log.info('batchGetDocuments stream %j', options);
|
|
724
|
-
return this.innerApiCalls.batchGetDocuments(request, options);
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Runs a query.
|
|
728
|
-
*
|
|
729
|
-
* @param {Object} request
|
|
730
|
-
* The request object that will be sent.
|
|
731
|
-
* @param {string} request.parent
|
|
732
|
-
* Required. The parent resource name. In the format:
|
|
733
|
-
* `projects/{project_id}/databases/{database_id}/documents` or
|
|
734
|
-
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
|
735
|
-
* For example:
|
|
736
|
-
* `projects/my-project/databases/my-database/documents` or
|
|
737
|
-
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
|
738
|
-
* @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery
|
|
739
|
-
* A structured query.
|
|
740
|
-
* @param {Buffer} request.transaction
|
|
741
|
-
* Reads documents in a transaction.
|
|
742
|
-
* @param {google.firestore.v1beta1.TransactionOptions} request.newTransaction
|
|
743
|
-
* Starts a new transaction and reads the documents.
|
|
744
|
-
* Defaults to a read-only transaction.
|
|
745
|
-
* The new transaction ID will be returned as the first response in the
|
|
746
|
-
* stream.
|
|
747
|
-
* @param {google.protobuf.Timestamp} request.readTime
|
|
748
|
-
* Reads documents as they were at the given time.
|
|
749
|
-
* This may not be older than 270 seconds.
|
|
750
|
-
* @param {object} [options]
|
|
751
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
752
|
-
* @returns {Stream}
|
|
753
|
-
* An object stream which emits {@link protos.google.firestore.v1beta1.RunQueryResponse|RunQueryResponse} on 'data' event.
|
|
754
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
755
|
-
* for more details and examples.
|
|
756
|
-
* @example <caption>include:samples/generated/v1beta1/firestore.run_query.js</caption>
|
|
757
|
-
* region_tag:firestore_v1beta1_generated_Firestore_RunQuery_async
|
|
758
|
-
*/
|
|
759
|
-
runQuery(request, options) {
|
|
760
|
-
request = request || {};
|
|
761
|
-
options = options || {};
|
|
762
|
-
options.otherArgs = options.otherArgs || {};
|
|
763
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
764
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
765
|
-
this._gaxModule.routingHeader.fromParams({
|
|
766
|
-
parent: request.parent ?? '',
|
|
767
|
-
});
|
|
768
|
-
this.initialize().catch((err) => {
|
|
769
|
-
throw err;
|
|
770
|
-
});
|
|
771
|
-
this._log.info('runQuery stream %j', options);
|
|
772
|
-
return this.innerApiCalls.runQuery(request, options);
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Streams batches of document updates and deletes, in order.
|
|
776
|
-
*
|
|
777
|
-
* @param {object} [options]
|
|
778
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
779
|
-
* @returns {Stream}
|
|
780
|
-
* An object stream which is both readable and writable. It accepts objects
|
|
781
|
-
* representing {@link protos.google.firestore.v1beta1.WriteRequest|WriteRequest} for write() method, and
|
|
782
|
-
* will emit objects representing {@link protos.google.firestore.v1beta1.WriteResponse|WriteResponse} on 'data' event asynchronously.
|
|
783
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation }
|
|
784
|
-
* for more details and examples.
|
|
785
|
-
* @example <caption>include:samples/generated/v1beta1/firestore.write.js</caption>
|
|
786
|
-
* region_tag:firestore_v1beta1_generated_Firestore_Write_async
|
|
787
|
-
*/
|
|
788
|
-
write(options) {
|
|
789
|
-
this.initialize().catch((err) => {
|
|
790
|
-
throw err;
|
|
791
|
-
});
|
|
792
|
-
this._log.info('write stream %j', options);
|
|
793
|
-
return this.innerApiCalls.write(null, options);
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* Listens to changes.
|
|
797
|
-
*
|
|
798
|
-
* @param {object} [options]
|
|
799
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
800
|
-
* @returns {Stream}
|
|
801
|
-
* An object stream which is both readable and writable. It accepts objects
|
|
802
|
-
* representing {@link protos.google.firestore.v1beta1.ListenRequest|ListenRequest} for write() method, and
|
|
803
|
-
* will emit objects representing {@link protos.google.firestore.v1beta1.ListenResponse|ListenResponse} on 'data' event asynchronously.
|
|
804
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation }
|
|
805
|
-
* for more details and examples.
|
|
806
|
-
* @example <caption>include:samples/generated/v1beta1/firestore.listen.js</caption>
|
|
807
|
-
* region_tag:firestore_v1beta1_generated_Firestore_Listen_async
|
|
808
|
-
*/
|
|
809
|
-
listen(options) {
|
|
810
|
-
this.initialize().catch((err) => {
|
|
811
|
-
throw err;
|
|
812
|
-
});
|
|
813
|
-
this._log.info('listen stream %j', options);
|
|
814
|
-
return this.innerApiCalls.listen(null, options);
|
|
815
|
-
}
|
|
816
|
-
listDocuments(request, optionsOrCallback, callback) {
|
|
817
|
-
request = request || {};
|
|
818
|
-
let options;
|
|
819
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
820
|
-
callback = optionsOrCallback;
|
|
821
|
-
options = {};
|
|
822
|
-
}
|
|
823
|
-
else {
|
|
824
|
-
options = optionsOrCallback;
|
|
825
|
-
}
|
|
826
|
-
options = options || {};
|
|
827
|
-
options.otherArgs = options.otherArgs || {};
|
|
828
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
829
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
830
|
-
this._gaxModule.routingHeader.fromParams({
|
|
831
|
-
parent: request.parent ?? '',
|
|
832
|
-
collection_id: request.collectionId?.toString() ?? '',
|
|
833
|
-
});
|
|
834
|
-
this.initialize().catch((err) => {
|
|
835
|
-
throw err;
|
|
836
|
-
});
|
|
837
|
-
const wrappedCallback = callback
|
|
838
|
-
? (error, values, nextPageRequest, rawResponse) => {
|
|
839
|
-
this._log.info('listDocuments values %j', values);
|
|
840
|
-
callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
|
|
841
|
-
}
|
|
842
|
-
: undefined;
|
|
843
|
-
this._log.info('listDocuments request %j', request);
|
|
844
|
-
return this.innerApiCalls
|
|
845
|
-
.listDocuments(request, options, wrappedCallback)
|
|
846
|
-
?.then(([response, input, output]) => {
|
|
847
|
-
this._log.info('listDocuments values %j', response);
|
|
848
|
-
return [response, input, output];
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* Equivalent to `listDocuments`, but returns a NodeJS Stream object.
|
|
853
|
-
* @param {Object} request
|
|
854
|
-
* The request object that will be sent.
|
|
855
|
-
* @param {string} request.parent
|
|
856
|
-
* Required. The parent resource name. In the format:
|
|
857
|
-
* `projects/{project_id}/databases/{database_id}/documents` or
|
|
858
|
-
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
|
859
|
-
* For example:
|
|
860
|
-
* `projects/my-project/databases/my-database/documents` or
|
|
861
|
-
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
|
862
|
-
* @param {string} request.collectionId
|
|
863
|
-
* Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
|
|
864
|
-
* or `messages`.
|
|
865
|
-
* @param {number} request.pageSize
|
|
866
|
-
* The maximum number of documents to return.
|
|
867
|
-
* @param {string} request.pageToken
|
|
868
|
-
* The `next_page_token` value returned from a previous List request, if any.
|
|
869
|
-
* @param {string} request.orderBy
|
|
870
|
-
* The order to sort results by. For example: `priority desc, name`.
|
|
871
|
-
* @param {google.firestore.v1beta1.DocumentMask} request.mask
|
|
872
|
-
* The fields to return. If not set, returns all fields.
|
|
873
|
-
*
|
|
874
|
-
* If a document has a field that is not present in this mask, that field
|
|
875
|
-
* will not be returned in the response.
|
|
876
|
-
* @param {Buffer} request.transaction
|
|
877
|
-
* Reads documents in a transaction.
|
|
878
|
-
* @param {google.protobuf.Timestamp} request.readTime
|
|
879
|
-
* Reads documents as they were at the given time.
|
|
880
|
-
* This may not be older than 270 seconds.
|
|
881
|
-
* @param {boolean} request.showMissing
|
|
882
|
-
* If the list should show missing documents. A missing document is a
|
|
883
|
-
* document that does not exist but has sub-documents. These documents will
|
|
884
|
-
* be returned with a key but will not have fields, {@link protos.google.firestore.v1beta1.Document.create_time|Document.create_time},
|
|
885
|
-
* or {@link protos.google.firestore.v1beta1.Document.update_time|Document.update_time} set.
|
|
886
|
-
*
|
|
887
|
-
* Requests with `show_missing` may not specify `where` or
|
|
888
|
-
* `order_by`.
|
|
889
|
-
* @param {object} [options]
|
|
890
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
891
|
-
* @returns {Stream}
|
|
892
|
-
* An object stream which emits an object representing {@link protos.google.firestore.v1beta1.Document|Document} on 'data' event.
|
|
893
|
-
* The client library will perform auto-pagination by default: it will call the API as many
|
|
894
|
-
* times as needed. Note that it can affect your quota.
|
|
895
|
-
* We recommend using `listDocumentsAsync()`
|
|
896
|
-
* method described below for async iteration which you can stop as needed.
|
|
897
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
898
|
-
* for more details and examples.
|
|
899
|
-
*/
|
|
900
|
-
listDocumentsStream(request, options) {
|
|
901
|
-
request = request || {};
|
|
902
|
-
options = options || {};
|
|
903
|
-
options.otherArgs = options.otherArgs || {};
|
|
904
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
905
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
906
|
-
this._gaxModule.routingHeader.fromParams({
|
|
907
|
-
parent: request.parent ?? '',
|
|
908
|
-
collection_id: request.collectionId?.toString() ?? '',
|
|
909
|
-
});
|
|
910
|
-
const defaultCallSettings = this._defaults['listDocuments'];
|
|
911
|
-
const callSettings = defaultCallSettings.merge(options);
|
|
912
|
-
this.initialize().catch((err) => {
|
|
913
|
-
throw err;
|
|
914
|
-
});
|
|
915
|
-
this._log.info('listDocuments stream %j', request);
|
|
916
|
-
return this.descriptors.page.listDocuments.createStream(this.innerApiCalls.listDocuments, request, callSettings);
|
|
917
|
-
}
|
|
918
|
-
/**
|
|
919
|
-
* Equivalent to `listDocuments`, but returns an iterable object.
|
|
920
|
-
*
|
|
921
|
-
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
|
922
|
-
* @param {Object} request
|
|
923
|
-
* The request object that will be sent.
|
|
924
|
-
* @param {string} request.parent
|
|
925
|
-
* Required. The parent resource name. In the format:
|
|
926
|
-
* `projects/{project_id}/databases/{database_id}/documents` or
|
|
927
|
-
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
|
928
|
-
* For example:
|
|
929
|
-
* `projects/my-project/databases/my-database/documents` or
|
|
930
|
-
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
|
931
|
-
* @param {string} request.collectionId
|
|
932
|
-
* Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
|
|
933
|
-
* or `messages`.
|
|
934
|
-
* @param {number} request.pageSize
|
|
935
|
-
* The maximum number of documents to return.
|
|
936
|
-
* @param {string} request.pageToken
|
|
937
|
-
* The `next_page_token` value returned from a previous List request, if any.
|
|
938
|
-
* @param {string} request.orderBy
|
|
939
|
-
* The order to sort results by. For example: `priority desc, name`.
|
|
940
|
-
* @param {google.firestore.v1beta1.DocumentMask} request.mask
|
|
941
|
-
* The fields to return. If not set, returns all fields.
|
|
942
|
-
*
|
|
943
|
-
* If a document has a field that is not present in this mask, that field
|
|
944
|
-
* will not be returned in the response.
|
|
945
|
-
* @param {Buffer} request.transaction
|
|
946
|
-
* Reads documents in a transaction.
|
|
947
|
-
* @param {google.protobuf.Timestamp} request.readTime
|
|
948
|
-
* Reads documents as they were at the given time.
|
|
949
|
-
* This may not be older than 270 seconds.
|
|
950
|
-
* @param {boolean} request.showMissing
|
|
951
|
-
* If the list should show missing documents. A missing document is a
|
|
952
|
-
* document that does not exist but has sub-documents. These documents will
|
|
953
|
-
* be returned with a key but will not have fields, {@link protos.google.firestore.v1beta1.Document.create_time|Document.create_time},
|
|
954
|
-
* or {@link protos.google.firestore.v1beta1.Document.update_time|Document.update_time} set.
|
|
955
|
-
*
|
|
956
|
-
* Requests with `show_missing` may not specify `where` or
|
|
957
|
-
* `order_by`.
|
|
958
|
-
* @param {object} [options]
|
|
959
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
960
|
-
* @returns {Object}
|
|
961
|
-
* An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
|
|
962
|
-
* When you iterate the returned iterable, each element will be an object representing
|
|
963
|
-
* {@link protos.google.firestore.v1beta1.Document|Document}. The API will be called under the hood as needed, once per the page,
|
|
964
|
-
* so you can stop the iteration when you don't need more results.
|
|
965
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
966
|
-
* for more details and examples.
|
|
967
|
-
* @example <caption>include:samples/generated/v1beta1/firestore.list_documents.js</caption>
|
|
968
|
-
* region_tag:firestore_v1beta1_generated_Firestore_ListDocuments_async
|
|
969
|
-
*/
|
|
970
|
-
listDocumentsAsync(request, options) {
|
|
971
|
-
request = request || {};
|
|
972
|
-
options = options || {};
|
|
973
|
-
options.otherArgs = options.otherArgs || {};
|
|
974
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
975
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
976
|
-
this._gaxModule.routingHeader.fromParams({
|
|
977
|
-
parent: request.parent ?? '',
|
|
978
|
-
collection_id: request.collectionId?.toString() ?? '',
|
|
979
|
-
});
|
|
980
|
-
const defaultCallSettings = this._defaults['listDocuments'];
|
|
981
|
-
const callSettings = defaultCallSettings.merge(options);
|
|
982
|
-
this.initialize().catch((err) => {
|
|
983
|
-
throw err;
|
|
984
|
-
});
|
|
985
|
-
this._log.info('listDocuments iterate %j', request);
|
|
986
|
-
return this.descriptors.page.listDocuments.asyncIterate(this.innerApiCalls['listDocuments'], request, callSettings);
|
|
987
|
-
}
|
|
988
|
-
partitionQuery(request, optionsOrCallback, callback) {
|
|
989
|
-
request = request || {};
|
|
990
|
-
let options;
|
|
991
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
992
|
-
callback = optionsOrCallback;
|
|
993
|
-
options = {};
|
|
994
|
-
}
|
|
995
|
-
else {
|
|
996
|
-
options = optionsOrCallback;
|
|
997
|
-
}
|
|
998
|
-
options = options || {};
|
|
999
|
-
options.otherArgs = options.otherArgs || {};
|
|
1000
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1001
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
1002
|
-
this._gaxModule.routingHeader.fromParams({
|
|
1003
|
-
parent: request.parent ?? '',
|
|
1004
|
-
});
|
|
1005
|
-
this.initialize().catch((err) => {
|
|
1006
|
-
throw err;
|
|
1007
|
-
});
|
|
1008
|
-
const wrappedCallback = callback
|
|
1009
|
-
? (error, values, nextPageRequest, rawResponse) => {
|
|
1010
|
-
this._log.info('partitionQuery values %j', values);
|
|
1011
|
-
callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
|
|
1012
|
-
}
|
|
1013
|
-
: undefined;
|
|
1014
|
-
this._log.info('partitionQuery request %j', request);
|
|
1015
|
-
return this.innerApiCalls
|
|
1016
|
-
.partitionQuery(request, options, wrappedCallback)
|
|
1017
|
-
?.then(([response, input, output]) => {
|
|
1018
|
-
this._log.info('partitionQuery values %j', response);
|
|
1019
|
-
return [response, input, output];
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* Equivalent to `partitionQuery`, but returns a NodeJS Stream object.
|
|
1024
|
-
* @param {Object} request
|
|
1025
|
-
* The request object that will be sent.
|
|
1026
|
-
* @param {string} request.parent
|
|
1027
|
-
* Required. The parent resource name. In the format:
|
|
1028
|
-
* `projects/{project_id}/databases/{database_id}/documents`.
|
|
1029
|
-
* Document resource names are not supported; only database resource names
|
|
1030
|
-
* can be specified.
|
|
1031
|
-
* @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery
|
|
1032
|
-
* A structured query.
|
|
1033
|
-
* Query must specify collection with all descendants and be ordered by name
|
|
1034
|
-
* ascending. Other filters, order bys, limits, offsets, and start/end
|
|
1035
|
-
* cursors are not supported.
|
|
1036
|
-
* @param {number} request.partitionCount
|
|
1037
|
-
* The desired maximum number of partition points.
|
|
1038
|
-
* The partitions may be returned across multiple pages of results.
|
|
1039
|
-
* The number must be positive. The actual number of partitions
|
|
1040
|
-
* returned may be fewer.
|
|
1041
|
-
*
|
|
1042
|
-
* For example, this may be set to one fewer than the number of parallel
|
|
1043
|
-
* queries to be run, or in running a data pipeline job, one fewer than the
|
|
1044
|
-
* number of workers or compute instances available.
|
|
1045
|
-
* @param {string} request.pageToken
|
|
1046
|
-
* The `next_page_token` value returned from a previous call to
|
|
1047
|
-
* PartitionQuery that may be used to get an additional set of results.
|
|
1048
|
-
* There are no ordering guarantees between sets of results. Thus, using
|
|
1049
|
-
* multiple sets of results will require merging the different result sets.
|
|
1050
|
-
*
|
|
1051
|
-
* For example, two subsequent calls using a page_token may return:
|
|
1052
|
-
*
|
|
1053
|
-
* * cursor B, cursor M, cursor Q
|
|
1054
|
-
* * cursor A, cursor U, cursor W
|
|
1055
|
-
*
|
|
1056
|
-
* To obtain a complete result set ordered with respect to the results of the
|
|
1057
|
-
* query supplied to PartitionQuery, the results sets should be merged:
|
|
1058
|
-
* cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
|
|
1059
|
-
* @param {number} request.pageSize
|
|
1060
|
-
* The maximum number of partitions to return in this call, subject to
|
|
1061
|
-
* `partition_count`.
|
|
1062
|
-
*
|
|
1063
|
-
* For example, if `partition_count` = 10 and `page_size` = 8, the first call
|
|
1064
|
-
* to PartitionQuery will return up to 8 partitions and a `next_page_token`
|
|
1065
|
-
* if more results exist. A second call to PartitionQuery will return up to
|
|
1066
|
-
* 2 partitions, to complete the total of 10 specified in `partition_count`.
|
|
1067
|
-
* @param {object} [options]
|
|
1068
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1069
|
-
* @returns {Stream}
|
|
1070
|
-
* An object stream which emits an object representing {@link protos.google.firestore.v1beta1.Cursor|Cursor} on 'data' event.
|
|
1071
|
-
* The client library will perform auto-pagination by default: it will call the API as many
|
|
1072
|
-
* times as needed. Note that it can affect your quota.
|
|
1073
|
-
* We recommend using `partitionQueryAsync()`
|
|
1074
|
-
* method described below for async iteration which you can stop as needed.
|
|
1075
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
1076
|
-
* for more details and examples.
|
|
1077
|
-
*/
|
|
1078
|
-
partitionQueryStream(request, options) {
|
|
1079
|
-
request = request || {};
|
|
1080
|
-
options = options || {};
|
|
1081
|
-
options.otherArgs = options.otherArgs || {};
|
|
1082
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1083
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
1084
|
-
this._gaxModule.routingHeader.fromParams({
|
|
1085
|
-
parent: request.parent ?? '',
|
|
1086
|
-
});
|
|
1087
|
-
const defaultCallSettings = this._defaults['partitionQuery'];
|
|
1088
|
-
const callSettings = defaultCallSettings.merge(options);
|
|
1089
|
-
this.initialize().catch((err) => {
|
|
1090
|
-
throw err;
|
|
1091
|
-
});
|
|
1092
|
-
this._log.info('partitionQuery stream %j', request);
|
|
1093
|
-
return this.descriptors.page.partitionQuery.createStream(this.innerApiCalls.partitionQuery, request, callSettings);
|
|
1094
|
-
}
|
|
1095
|
-
/**
|
|
1096
|
-
* Equivalent to `partitionQuery`, but returns an iterable object.
|
|
1097
|
-
*
|
|
1098
|
-
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
|
1099
|
-
* @param {Object} request
|
|
1100
|
-
* The request object that will be sent.
|
|
1101
|
-
* @param {string} request.parent
|
|
1102
|
-
* Required. The parent resource name. In the format:
|
|
1103
|
-
* `projects/{project_id}/databases/{database_id}/documents`.
|
|
1104
|
-
* Document resource names are not supported; only database resource names
|
|
1105
|
-
* can be specified.
|
|
1106
|
-
* @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery
|
|
1107
|
-
* A structured query.
|
|
1108
|
-
* Query must specify collection with all descendants and be ordered by name
|
|
1109
|
-
* ascending. Other filters, order bys, limits, offsets, and start/end
|
|
1110
|
-
* cursors are not supported.
|
|
1111
|
-
* @param {number} request.partitionCount
|
|
1112
|
-
* The desired maximum number of partition points.
|
|
1113
|
-
* The partitions may be returned across multiple pages of results.
|
|
1114
|
-
* The number must be positive. The actual number of partitions
|
|
1115
|
-
* returned may be fewer.
|
|
1116
|
-
*
|
|
1117
|
-
* For example, this may be set to one fewer than the number of parallel
|
|
1118
|
-
* queries to be run, or in running a data pipeline job, one fewer than the
|
|
1119
|
-
* number of workers or compute instances available.
|
|
1120
|
-
* @param {string} request.pageToken
|
|
1121
|
-
* The `next_page_token` value returned from a previous call to
|
|
1122
|
-
* PartitionQuery that may be used to get an additional set of results.
|
|
1123
|
-
* There are no ordering guarantees between sets of results. Thus, using
|
|
1124
|
-
* multiple sets of results will require merging the different result sets.
|
|
1125
|
-
*
|
|
1126
|
-
* For example, two subsequent calls using a page_token may return:
|
|
1127
|
-
*
|
|
1128
|
-
* * cursor B, cursor M, cursor Q
|
|
1129
|
-
* * cursor A, cursor U, cursor W
|
|
1130
|
-
*
|
|
1131
|
-
* To obtain a complete result set ordered with respect to the results of the
|
|
1132
|
-
* query supplied to PartitionQuery, the results sets should be merged:
|
|
1133
|
-
* cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
|
|
1134
|
-
* @param {number} request.pageSize
|
|
1135
|
-
* The maximum number of partitions to return in this call, subject to
|
|
1136
|
-
* `partition_count`.
|
|
1137
|
-
*
|
|
1138
|
-
* For example, if `partition_count` = 10 and `page_size` = 8, the first call
|
|
1139
|
-
* to PartitionQuery will return up to 8 partitions and a `next_page_token`
|
|
1140
|
-
* if more results exist. A second call to PartitionQuery will return up to
|
|
1141
|
-
* 2 partitions, to complete the total of 10 specified in `partition_count`.
|
|
1142
|
-
* @param {object} [options]
|
|
1143
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1144
|
-
* @returns {Object}
|
|
1145
|
-
* An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
|
|
1146
|
-
* When you iterate the returned iterable, each element will be an object representing
|
|
1147
|
-
* {@link protos.google.firestore.v1beta1.Cursor|Cursor}. The API will be called under the hood as needed, once per the page,
|
|
1148
|
-
* so you can stop the iteration when you don't need more results.
|
|
1149
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
1150
|
-
* for more details and examples.
|
|
1151
|
-
* @example <caption>include:samples/generated/v1beta1/firestore.partition_query.js</caption>
|
|
1152
|
-
* region_tag:firestore_v1beta1_generated_Firestore_PartitionQuery_async
|
|
1153
|
-
*/
|
|
1154
|
-
partitionQueryAsync(request, options) {
|
|
1155
|
-
request = request || {};
|
|
1156
|
-
options = options || {};
|
|
1157
|
-
options.otherArgs = options.otherArgs || {};
|
|
1158
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1159
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
1160
|
-
this._gaxModule.routingHeader.fromParams({
|
|
1161
|
-
parent: request.parent ?? '',
|
|
1162
|
-
});
|
|
1163
|
-
const defaultCallSettings = this._defaults['partitionQuery'];
|
|
1164
|
-
const callSettings = defaultCallSettings.merge(options);
|
|
1165
|
-
this.initialize().catch((err) => {
|
|
1166
|
-
throw err;
|
|
1167
|
-
});
|
|
1168
|
-
this._log.info('partitionQuery iterate %j', request);
|
|
1169
|
-
return this.descriptors.page.partitionQuery.asyncIterate(this.innerApiCalls['partitionQuery'], request, callSettings);
|
|
1170
|
-
}
|
|
1171
|
-
listCollectionIds(request, optionsOrCallback, callback) {
|
|
1172
|
-
request = request || {};
|
|
1173
|
-
let options;
|
|
1174
|
-
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
1175
|
-
callback = optionsOrCallback;
|
|
1176
|
-
options = {};
|
|
1177
|
-
}
|
|
1178
|
-
else {
|
|
1179
|
-
options = optionsOrCallback;
|
|
1180
|
-
}
|
|
1181
|
-
options = options || {};
|
|
1182
|
-
options.otherArgs = options.otherArgs || {};
|
|
1183
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1184
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
1185
|
-
this._gaxModule.routingHeader.fromParams({
|
|
1186
|
-
parent: request.parent ?? '',
|
|
1187
|
-
});
|
|
1188
|
-
this.initialize().catch((err) => {
|
|
1189
|
-
throw err;
|
|
1190
|
-
});
|
|
1191
|
-
const wrappedCallback = callback
|
|
1192
|
-
? (error, values, nextPageRequest, rawResponse) => {
|
|
1193
|
-
this._log.info('listCollectionIds values %j', values);
|
|
1194
|
-
callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
|
|
1195
|
-
}
|
|
1196
|
-
: undefined;
|
|
1197
|
-
this._log.info('listCollectionIds request %j', request);
|
|
1198
|
-
return this.innerApiCalls
|
|
1199
|
-
.listCollectionIds(request, options, wrappedCallback)
|
|
1200
|
-
?.then(([response, input, output]) => {
|
|
1201
|
-
this._log.info('listCollectionIds values %j', response);
|
|
1202
|
-
return [response, input, output];
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
/**
|
|
1206
|
-
* Equivalent to `listCollectionIds`, but returns a NodeJS Stream object.
|
|
1207
|
-
* @param {Object} request
|
|
1208
|
-
* The request object that will be sent.
|
|
1209
|
-
* @param {string} request.parent
|
|
1210
|
-
* Required. The parent document. In the format:
|
|
1211
|
-
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
|
1212
|
-
* For example:
|
|
1213
|
-
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
|
1214
|
-
* @param {number} request.pageSize
|
|
1215
|
-
* The maximum number of results to return.
|
|
1216
|
-
* @param {string} request.pageToken
|
|
1217
|
-
* A page token. Must be a value from
|
|
1218
|
-
* {@link protos.google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}.
|
|
1219
|
-
* @param {object} [options]
|
|
1220
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1221
|
-
* @returns {Stream}
|
|
1222
|
-
* An object stream which emits an object representing string on 'data' event.
|
|
1223
|
-
* The client library will perform auto-pagination by default: it will call the API as many
|
|
1224
|
-
* times as needed. Note that it can affect your quota.
|
|
1225
|
-
* We recommend using `listCollectionIdsAsync()`
|
|
1226
|
-
* method described below for async iteration which you can stop as needed.
|
|
1227
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
1228
|
-
* for more details and examples.
|
|
1229
|
-
*/
|
|
1230
|
-
listCollectionIdsStream(request, options) {
|
|
1231
|
-
request = request || {};
|
|
1232
|
-
options = options || {};
|
|
1233
|
-
options.otherArgs = options.otherArgs || {};
|
|
1234
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1235
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
1236
|
-
this._gaxModule.routingHeader.fromParams({
|
|
1237
|
-
parent: request.parent ?? '',
|
|
1238
|
-
});
|
|
1239
|
-
const defaultCallSettings = this._defaults['listCollectionIds'];
|
|
1240
|
-
const callSettings = defaultCallSettings.merge(options);
|
|
1241
|
-
this.initialize().catch((err) => {
|
|
1242
|
-
throw err;
|
|
1243
|
-
});
|
|
1244
|
-
this._log.info('listCollectionIds stream %j', request);
|
|
1245
|
-
return this.descriptors.page.listCollectionIds.createStream(this.innerApiCalls.listCollectionIds, request, callSettings);
|
|
1246
|
-
}
|
|
1247
|
-
/**
|
|
1248
|
-
* Equivalent to `listCollectionIds`, but returns an iterable object.
|
|
1249
|
-
*
|
|
1250
|
-
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
|
1251
|
-
* @param {Object} request
|
|
1252
|
-
* The request object that will be sent.
|
|
1253
|
-
* @param {string} request.parent
|
|
1254
|
-
* Required. The parent document. In the format:
|
|
1255
|
-
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
|
1256
|
-
* For example:
|
|
1257
|
-
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
|
1258
|
-
* @param {number} request.pageSize
|
|
1259
|
-
* The maximum number of results to return.
|
|
1260
|
-
* @param {string} request.pageToken
|
|
1261
|
-
* A page token. Must be a value from
|
|
1262
|
-
* {@link protos.google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}.
|
|
1263
|
-
* @param {object} [options]
|
|
1264
|
-
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1265
|
-
* @returns {Object}
|
|
1266
|
-
* An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
|
|
1267
|
-
* When you iterate the returned iterable, each element will be an object representing
|
|
1268
|
-
* string. The API will be called under the hood as needed, once per the page,
|
|
1269
|
-
* so you can stop the iteration when you don't need more results.
|
|
1270
|
-
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
1271
|
-
* for more details and examples.
|
|
1272
|
-
* @example <caption>include:samples/generated/v1beta1/firestore.list_collection_ids.js</caption>
|
|
1273
|
-
* region_tag:firestore_v1beta1_generated_Firestore_ListCollectionIds_async
|
|
1274
|
-
*/
|
|
1275
|
-
listCollectionIdsAsync(request, options) {
|
|
1276
|
-
request = request || {};
|
|
1277
|
-
options = options || {};
|
|
1278
|
-
options.otherArgs = options.otherArgs || {};
|
|
1279
|
-
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1280
|
-
options.otherArgs.headers['x-goog-request-params'] =
|
|
1281
|
-
this._gaxModule.routingHeader.fromParams({
|
|
1282
|
-
parent: request.parent ?? '',
|
|
1283
|
-
});
|
|
1284
|
-
const defaultCallSettings = this._defaults['listCollectionIds'];
|
|
1285
|
-
const callSettings = defaultCallSettings.merge(options);
|
|
1286
|
-
this.initialize().catch((err) => {
|
|
1287
|
-
throw err;
|
|
1288
|
-
});
|
|
1289
|
-
this._log.info('listCollectionIds iterate %j', request);
|
|
1290
|
-
return this.descriptors.page.listCollectionIds.asyncIterate(this.innerApiCalls['listCollectionIds'], request, callSettings);
|
|
1291
|
-
}
|
|
1292
|
-
/**
|
|
1293
|
-
* Terminate the gRPC channel and close the client.
|
|
1294
|
-
*
|
|
1295
|
-
* The client will no longer be usable and all future behavior is undefined.
|
|
1296
|
-
* @returns {Promise} A promise that resolves when the client is closed.
|
|
1297
|
-
*/
|
|
1298
|
-
close() {
|
|
1299
|
-
if (this.firestoreStub && !this._terminated) {
|
|
1300
|
-
return this.firestoreStub.then((stub) => {
|
|
1301
|
-
this._log.info('ending gRPC channel');
|
|
1302
|
-
this._terminated = true;
|
|
1303
|
-
stub.close();
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
return Promise.resolve();
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
exports.FirestoreClient = FirestoreClient;
|
|
1310
|
-
//# sourceMappingURL=firestore_client.js.map
|