@glissandoo/lib 1.32.10 → 1.32.11
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/models/Communication/Comment/index.d.ts +1 -1
- package/models/Communication/Comment/types.d.ts +1 -1
- package/models/Communication/index.d.ts +4 -4
- package/models/Communication/types.d.ts +1 -1
- package/models/Counters/Group/Analytics/index.d.ts +2 -2
- package/models/Counters/Group/Analytics/types.d.ts +1 -1
- package/models/Counters/Group/index.d.ts +2 -2
- package/models/Counters/Group/types.d.ts +1 -1
- package/models/Counters/event.d.ts +1 -1
- package/models/Counters/index.d.ts +1 -1
- package/models/Evento/Player/index.d.ts +1 -1
- package/models/Evento/Player/types.d.ts +1 -1
- package/models/Evento/Repertory/index.d.ts +1 -1
- package/models/Evento/Repertory/types.d.ts +1 -1
- package/models/Evento/basic.d.ts +3 -3
- package/models/Evento/index.d.ts +7 -7
- package/models/Evento/promoter.d.ts +1 -1
- package/models/Evento/types.d.ts +1 -1
- package/models/Federation/Partnership/index.d.ts +3 -3
- package/models/Federation/Partnership/types.d.ts +1 -1
- package/models/Federation/index.d.ts +4 -4
- package/models/Federation/types.d.ts +1 -1
- package/models/Group/Analytics/index.d.ts +1 -1
- package/models/Group/Analytics/types.d.ts +1 -1
- package/models/Group/Event/index.d.ts +2 -2
- package/models/Group/Event/types.d.ts +1 -1
- package/models/Group/Player/Event/index.d.ts +2 -2
- package/models/Group/Player/Event/types.d.ts +1 -1
- package/models/Group/Player/Log/index.d.ts +2 -2
- package/models/Group/Player/Log/types.d.ts +1 -1
- package/models/Group/Player/index.d.ts +1 -1
- package/models/Group/Player/types.d.ts +1 -1
- package/models/Group/Repertory/index.d.ts +1 -1
- package/models/Group/Repertory/types.d.ts +1 -1
- package/models/Group/basic.d.ts +2 -2
- package/models/Group/index.d.ts +1 -1
- package/models/Group/index.js +2 -2
- package/models/Group/types.d.ts +1 -1
- package/models/Metrics/index.d.ts +1 -1
- package/models/Metrics/types.d.ts +1 -1
- package/models/Model/index.d.ts +1 -1
- package/models/Model/lang.d.ts +1 -1
- package/models/Notification/index.d.ts +1 -1
- package/models/Notification/types.d.ts +1 -1
- package/models/Partner/basic.d.ts +4 -4
- package/models/Partner/index.d.ts +2 -2
- package/models/Partner/tiny.d.ts +1 -1
- package/models/Partner/types.d.ts +1 -1
- package/models/Partnership/Group/index.d.ts +5 -5
- package/models/Partnership/Group/types.d.ts +1 -1
- package/models/Partnership/Partner/Subscription/index.d.ts +5 -5
- package/models/Partnership/Partner/Subscription/types.d.ts +1 -1
- package/models/Partnership/Partner/index.d.ts +1 -1
- package/models/Partnership/Payment/index.d.ts +1 -1
- package/models/Partnership/Plan/basic.d.ts +1 -1
- package/models/Partnership/Plan/index.d.ts +3 -3
- package/models/Partnership/Plan/types.d.ts +1 -1
- package/models/Partnership/basic.d.ts +1 -1
- package/models/Partnership/index.d.ts +2 -2
- package/models/Partnership/types.d.ts +1 -1
- package/models/Payment/basic.d.ts +1 -1
- package/models/Payment/index.d.ts +1 -1
- package/models/Payment/types.d.ts +1 -1
- package/models/Player/basic.d.ts +1 -1
- package/models/Repertory/basic.d.ts +1 -1
- package/models/User/Group/index.d.ts +2 -2
- package/models/User/Group/types.d.ts +1 -1
- package/models/User/Notification/index.d.ts +1 -1
- package/models/User/Notification/types.d.ts +1 -1
- package/models/User/basic.d.ts +1 -1
- package/models/User/index.d.ts +6 -6
- package/models/User/types.d.ts +1 -1
- package/package.json +1 -1
- package/types/firestore.d.ts +1481 -1732
- package/types/firestore.js +57 -0
- package/types/firestore.ts +1998 -0
package/types/firestore.d.ts
CHANGED
|
@@ -13,27 +13,22 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
// We deliberately use `any` in the external API to not impose type-checking
|
|
18
|
-
// on end users.
|
|
19
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
|
-
|
|
21
|
-
// Declare a global (ambient) namespace
|
|
22
|
-
// (used when not using import statement, but just script include).
|
|
23
|
-
|
|
16
|
+
/// <reference types="node" />
|
|
24
17
|
/**
|
|
25
18
|
* Document data (for use with `DocumentReference.set()`) consists of fields
|
|
26
19
|
* mapped to values.
|
|
27
20
|
*/
|
|
28
|
-
export type DocumentData = {
|
|
29
|
-
|
|
21
|
+
export type DocumentData = {
|
|
22
|
+
[field: string]: any;
|
|
23
|
+
};
|
|
30
24
|
/**
|
|
31
25
|
* Update data (for use with `DocumentReference.update()`) consists of field
|
|
32
26
|
* paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots
|
|
33
27
|
* reference nested fields within the document.
|
|
34
28
|
*/
|
|
35
|
-
export type UpdateData = {
|
|
36
|
-
|
|
29
|
+
export type UpdateData = {
|
|
30
|
+
[fieldPath: string]: any;
|
|
31
|
+
};
|
|
37
32
|
/**
|
|
38
33
|
* Converter used by `withConverter()` to transform user objects of type T
|
|
39
34
|
* into Firestore data.
|
|
@@ -74,281 +69,253 @@ export type UpdateData = { [fieldPath: string]: any };
|
|
|
74
69
|
* }
|
|
75
70
|
*/
|
|
76
71
|
export interface FirestoreDataConverter<T> {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
fromFirestore(snapshot: QueryDocumentSnapshot): T;
|
|
72
|
+
/**
|
|
73
|
+
* Called by the Firestore SDK to convert a custom model object of type T
|
|
74
|
+
* into a plain Javascript object (suitable for writing directly to the
|
|
75
|
+
* Firestore database). To use set() with `merge` and `mergeFields`,
|
|
76
|
+
* toFirestore() must be defined with `Partial<T>`.
|
|
77
|
+
*/
|
|
78
|
+
toFirestore(modelObject: T): DocumentData;
|
|
79
|
+
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
|
|
80
|
+
/**
|
|
81
|
+
* Called by the Firestore SDK to convert Firestore data into an object of
|
|
82
|
+
* type T.
|
|
83
|
+
*/
|
|
84
|
+
fromFirestore(snapshot: QueryDocumentSnapshot): T;
|
|
91
85
|
}
|
|
92
|
-
|
|
93
86
|
/**
|
|
94
87
|
* Settings used to directly configure a `Firestore` instance.
|
|
95
88
|
*/
|
|
96
89
|
export interface Settings {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* and not written to Firestore. If set `false` or omitted, the SDK throws
|
|
154
|
-
* an exception when it encounters properties of type `undefined`.
|
|
155
|
-
*/
|
|
156
|
-
ignoreUndefinedProperties?: boolean;
|
|
157
|
-
|
|
158
|
-
[key: string]: any; // Accept other properties, such as GRPC settings.
|
|
90
|
+
/**
|
|
91
|
+
* The project ID from the Google Developer's Console, e.g.
|
|
92
|
+
* 'grape-spaceship-123'. We will also check the environment variable
|
|
93
|
+
* GCLOUD_PROJECT for your project ID. Can be omitted in environments that
|
|
94
|
+
* support {@link https://cloud.google.com/docs/authentication Application
|
|
95
|
+
* Default Credentials}
|
|
96
|
+
*/
|
|
97
|
+
projectId?: string;
|
|
98
|
+
/** The hostname to connect to. */
|
|
99
|
+
host?: string;
|
|
100
|
+
/** The port to connect to. */
|
|
101
|
+
port?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Local file containing the Service Account credentials as downloaded from
|
|
104
|
+
* the Google Developers Console. Can be omitted in environments that
|
|
105
|
+
* support {@link https://cloud.google.com/docs/authentication Application
|
|
106
|
+
* Default Credentials}. To configure Firestore with custom credentials, use
|
|
107
|
+
* the `credentials` property to provide the `client_email` and
|
|
108
|
+
* `private_key` of your service account.
|
|
109
|
+
*/
|
|
110
|
+
keyFilename?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The 'client_email' and 'private_key' properties of the service account
|
|
113
|
+
* to use with your Firestore project. Can be omitted in environments that
|
|
114
|
+
* support {@link https://cloud.google.com/docs/authentication Application
|
|
115
|
+
* Default Credentials}. If your credentials are stored in a JSON file, you
|
|
116
|
+
* can specify a `keyFilename` instead.
|
|
117
|
+
*/
|
|
118
|
+
credentials?: {
|
|
119
|
+
client_email?: string;
|
|
120
|
+
private_key?: string;
|
|
121
|
+
};
|
|
122
|
+
/** Whether to use SSL when connecting. */
|
|
123
|
+
ssl?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* The maximum number of idle GRPC channels to keep. A smaller number of idle
|
|
126
|
+
* channels reduces memory usage but increases request latency for clients
|
|
127
|
+
* with fluctuating request rates. If set to 0, shuts down all GRPC channels
|
|
128
|
+
* when the client becomes idle. Defaults to 1.
|
|
129
|
+
*/
|
|
130
|
+
maxIdleChannels?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Whether to use `BigInt` for integer types when deserializing Firestore
|
|
133
|
+
* Documents. Regardless of magnitude, all integer values are returned as
|
|
134
|
+
* `BigInt` to match the precision of the Firestore backend. Floating point
|
|
135
|
+
* numbers continue to use JavaScript's `number` type.
|
|
136
|
+
*/
|
|
137
|
+
useBigInt?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Whether to skip nested properties that are set to `undefined` during
|
|
140
|
+
* object serialization. If set to `true`, these properties are skipped
|
|
141
|
+
* and not written to Firestore. If set `false` or omitted, the SDK throws
|
|
142
|
+
* an exception when it encounters properties of type `undefined`.
|
|
143
|
+
*/
|
|
144
|
+
ignoreUndefinedProperties?: boolean;
|
|
145
|
+
[key: string]: any;
|
|
159
146
|
}
|
|
160
|
-
|
|
161
147
|
/**
|
|
162
148
|
* `Firestore` represents a Firestore Database and is the entry point for all
|
|
163
149
|
* Firestore operations.
|
|
164
150
|
*/
|
|
165
|
-
export class Firestore {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
* a bundle.
|
|
333
|
-
*
|
|
334
|
-
* @param bundleId The ID of the bundle. When loaded on clients, client SDKs use this ID
|
|
335
|
-
* and the timestamp associated with the bundle to tell if it has been loaded already.
|
|
336
|
-
* If not specified, a random identifier will be used.
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
* @example
|
|
340
|
-
* const bundle = firestore.bundle('data-bundle');
|
|
341
|
-
* const docSnapshot = await firestore.doc('abc/123').get();
|
|
342
|
-
* const querySnapshot = await firestore.collection('coll').get();
|
|
343
|
-
*
|
|
344
|
-
* const bundleBuffer = bundle.add(docSnapshot); // Add a document
|
|
345
|
-
* .add('coll-query', querySnapshot) // Add a named query.
|
|
346
|
-
* .build()
|
|
347
|
-
* // Save `bundleBuffer` to CDN or stream it to clients.
|
|
348
|
-
*/
|
|
349
|
-
bundle(bundleId?: string): BundleBuilder;
|
|
151
|
+
export declare class Firestore {
|
|
152
|
+
/**
|
|
153
|
+
* @param settings Configuration object. See [Firestore Documentation]
|
|
154
|
+
* {@link https://firebase.google.com/docs/firestore/}
|
|
155
|
+
*/
|
|
156
|
+
constructor(settings?: Settings);
|
|
157
|
+
/**
|
|
158
|
+
* Specifies custom settings to be used to configure the `Firestore`
|
|
159
|
+
* instance. Can only be invoked once and before any other Firestore
|
|
160
|
+
* method.
|
|
161
|
+
*
|
|
162
|
+
* If settings are provided via both `settings()` and the `Firestore`
|
|
163
|
+
* constructor, both settings objects are merged and any settings provided
|
|
164
|
+
* via `settings()` take precedence.
|
|
165
|
+
*
|
|
166
|
+
* @param {object} settings The settings to use for all Firestore
|
|
167
|
+
* operations.
|
|
168
|
+
*/
|
|
169
|
+
settings(settings: Settings): void;
|
|
170
|
+
/**
|
|
171
|
+
* Gets a `CollectionReference` instance that refers to the collection at
|
|
172
|
+
* the specified path.
|
|
173
|
+
*
|
|
174
|
+
* @param collectionPath A slash-separated path to a collection.
|
|
175
|
+
* @return The `CollectionReference` instance.
|
|
176
|
+
*/
|
|
177
|
+
collection(collectionPath: string): CollectionReference<DocumentData>;
|
|
178
|
+
/**
|
|
179
|
+
* Gets a `DocumentReference` instance that refers to the document at the
|
|
180
|
+
* specified path.
|
|
181
|
+
*
|
|
182
|
+
* @param documentPath A slash-separated path to a document.
|
|
183
|
+
* @return The `DocumentReference` instance.
|
|
184
|
+
*/
|
|
185
|
+
doc(documentPath: string): DocumentReference<DocumentData>;
|
|
186
|
+
/**
|
|
187
|
+
* Creates and returns a new Query that includes all documents in the
|
|
188
|
+
* database that are contained in a collection or subcollection with the
|
|
189
|
+
* given collectionId.
|
|
190
|
+
*
|
|
191
|
+
* @param collectionId Identifies the collections to query over. Every
|
|
192
|
+
* collection or subcollection with this ID as the last segment of its path
|
|
193
|
+
* will be included. Cannot contain a slash.
|
|
194
|
+
* @return The created `CollectionGroup`.
|
|
195
|
+
*/
|
|
196
|
+
collectionGroup(collectionId: string): CollectionGroup<DocumentData>;
|
|
197
|
+
/**
|
|
198
|
+
* Retrieves multiple documents from Firestore.
|
|
199
|
+
*
|
|
200
|
+
* The first argument is required and must be of type `DocumentReference`
|
|
201
|
+
* followed by any additional `DocumentReference` documents. If used, the
|
|
202
|
+
* optional `ReadOptions` must be the last argument.
|
|
203
|
+
*
|
|
204
|
+
* @param {Array.<DocumentReference|ReadOptions>} documentRefsOrReadOptions
|
|
205
|
+
* The `DocumentReferences` to receive, followed by an optional field
|
|
206
|
+
* mask.
|
|
207
|
+
* @return A Promise that resolves with an array of resulting document
|
|
208
|
+
* snapshots.
|
|
209
|
+
*/
|
|
210
|
+
getAll(...documentRefsOrReadOptions: Array<DocumentReference<DocumentData> | ReadOptions>): Promise<Array<DocumentSnapshot<DocumentData>>>;
|
|
211
|
+
/**
|
|
212
|
+
* Recursively deletes all documents and subcollections at and under the
|
|
213
|
+
* specified level.
|
|
214
|
+
*
|
|
215
|
+
* If any delete fails, the promise is rejected with an error message
|
|
216
|
+
* containing the number of failed deletes and the stack trace of the last
|
|
217
|
+
* failed delete. The provided reference is deleted regardless of whether
|
|
218
|
+
* all deletes succeeded.
|
|
219
|
+
*
|
|
220
|
+
* `recursiveDelete()` uses a BulkWriter instance with default settings to
|
|
221
|
+
* perform the deletes. To customize throttling rates or add success/error
|
|
222
|
+
* callbacks, pass in a custom BulkWriter instance.
|
|
223
|
+
*
|
|
224
|
+
* @param ref The reference of a document or collection to delete.
|
|
225
|
+
* @param bulkWriter A custom BulkWriter instance used to perform the
|
|
226
|
+
* deletes.
|
|
227
|
+
* @return A promise that resolves when all deletes have been performed.
|
|
228
|
+
* The promise is rejected if any of the deletes fail.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* // Recursively delete a reference and log the references of failures.
|
|
232
|
+
* const bulkWriter = firestore.bulkWriter();
|
|
233
|
+
* bulkWriter
|
|
234
|
+
* .onWriteError((error) => {
|
|
235
|
+
* if (
|
|
236
|
+
* error.failedAttempts < MAX_RETRY_ATTEMPTS
|
|
237
|
+
* ) {
|
|
238
|
+
* return true;
|
|
239
|
+
* } else {
|
|
240
|
+
* console.log('Failed write at document: ', error.documentRef.path);
|
|
241
|
+
* return false;
|
|
242
|
+
* }
|
|
243
|
+
* });
|
|
244
|
+
* await firestore.recursiveDelete(docRef, bulkWriter);
|
|
245
|
+
*/
|
|
246
|
+
recursiveDelete(ref: CollectionReference<unknown> | DocumentReference<unknown>, bulkWriter?: BulkWriter): Promise<void>;
|
|
247
|
+
/**
|
|
248
|
+
* Terminates the Firestore client and closes all open streams.
|
|
249
|
+
*
|
|
250
|
+
* @return A Promise that resolves when the client is terminated.
|
|
251
|
+
*/
|
|
252
|
+
terminate(): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Fetches the root collections that are associated with this Firestore
|
|
255
|
+
* database.
|
|
256
|
+
*
|
|
257
|
+
* @returns A Promise that resolves with an array of CollectionReferences.
|
|
258
|
+
*/
|
|
259
|
+
listCollections(): Promise<Array<CollectionReference<DocumentData>>>;
|
|
260
|
+
/**
|
|
261
|
+
* Executes the given updateFunction and commits the changes applied within
|
|
262
|
+
* the transaction.
|
|
263
|
+
*
|
|
264
|
+
* You can use the transaction object passed to 'updateFunction' to read and
|
|
265
|
+
* modify Firestore documents under lock. Transactions are committed once
|
|
266
|
+
* 'updateFunction' resolves and attempted up to five times on failure.
|
|
267
|
+
*
|
|
268
|
+
* @param updateFunction The function to execute within the transaction
|
|
269
|
+
* context.
|
|
270
|
+
* @param {object=} transactionOptions Transaction options.
|
|
271
|
+
* @param {number=} transactionOptions.maxAttempts The maximum number of
|
|
272
|
+
* attempts for this transaction.
|
|
273
|
+
* @return If the transaction completed successfully or was explicitly
|
|
274
|
+
* aborted (by the updateFunction returning a failed Promise), the Promise
|
|
275
|
+
* returned by the updateFunction will be returned here. Else if the
|
|
276
|
+
* transaction failed, a rejected Promise with the corresponding failure
|
|
277
|
+
* error will be returned.
|
|
278
|
+
*/
|
|
279
|
+
runTransaction<T>(updateFunction: (transaction: Transaction) => Promise<T>, transactionOptions?: {
|
|
280
|
+
maxAttempts?: number;
|
|
281
|
+
}): Promise<T>;
|
|
282
|
+
/**
|
|
283
|
+
* Creates a write batch, used for performing multiple writes as a single
|
|
284
|
+
* atomic operation.
|
|
285
|
+
*/
|
|
286
|
+
batch(): WriteBatch;
|
|
287
|
+
/**
|
|
288
|
+
* Creates a [BulkWriter]{@link BulkWriter}, used for performing
|
|
289
|
+
* multiple writes in parallel. Gradually ramps up writes as specified
|
|
290
|
+
* by the 500/50/5 rule.
|
|
291
|
+
*
|
|
292
|
+
* @see https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic
|
|
293
|
+
*
|
|
294
|
+
* @param options An options object used to configure the throttling
|
|
295
|
+
* behavior for the underlying BulkWriter.
|
|
296
|
+
*/
|
|
297
|
+
bulkWriter(options?: BulkWriterOptions): BulkWriter;
|
|
298
|
+
/**
|
|
299
|
+
* Creates a new `BundleBuilder` instance to package selected Firestore data into
|
|
300
|
+
* a bundle.
|
|
301
|
+
*
|
|
302
|
+
* @param bundleId The ID of the bundle. When loaded on clients, client SDKs use this ID
|
|
303
|
+
* and the timestamp associated with the bundle to tell if it has been loaded already.
|
|
304
|
+
* If not specified, a random identifier will be used.
|
|
305
|
+
*
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* const bundle = firestore.bundle('data-bundle');
|
|
309
|
+
* const docSnapshot = await firestore.doc('abc/123').get();
|
|
310
|
+
* const querySnapshot = await firestore.collection('coll').get();
|
|
311
|
+
*
|
|
312
|
+
* const bundleBuffer = bundle.add(docSnapshot); // Add a document
|
|
313
|
+
* .add('coll-query', querySnapshot) // Add a named query.
|
|
314
|
+
* .build()
|
|
315
|
+
* // Save `bundleBuffer` to CDN or stream it to clients.
|
|
316
|
+
*/
|
|
317
|
+
bundle(bundleId?: string): BundleBuilder;
|
|
350
318
|
}
|
|
351
|
-
|
|
352
319
|
/**
|
|
353
320
|
* An immutable object representing a geo point in Firestore. The geo point
|
|
354
321
|
* is represented as latitude/longitude pair.
|
|
@@ -356,384 +323,333 @@ export class Firestore {
|
|
|
356
323
|
* Latitude values are in the range of [-90, 90].
|
|
357
324
|
* Longitude values are in the range of [-180, 180].
|
|
358
325
|
*/
|
|
359
|
-
export class GeoPoint {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
*/
|
|
377
|
-
isEqual(other: GeoPoint): boolean;
|
|
326
|
+
export declare class GeoPoint {
|
|
327
|
+
/**
|
|
328
|
+
* Creates a new immutable GeoPoint object with the provided latitude and
|
|
329
|
+
* longitude values.
|
|
330
|
+
* @param latitude The latitude as number between -90 and 90.
|
|
331
|
+
* @param longitude The longitude as number between -180 and 180.
|
|
332
|
+
*/
|
|
333
|
+
constructor(latitude: number, longitude: number);
|
|
334
|
+
readonly latitude: number;
|
|
335
|
+
readonly longitude: number;
|
|
336
|
+
/**
|
|
337
|
+
* Returns true if this `GeoPoint` is equal to the provided one.
|
|
338
|
+
*
|
|
339
|
+
* @param other The `GeoPoint` to compare against.
|
|
340
|
+
* @return true if this `GeoPoint` is equal to the provided one.
|
|
341
|
+
*/
|
|
342
|
+
isEqual(other: GeoPoint): boolean;
|
|
378
343
|
}
|
|
379
|
-
|
|
380
344
|
/**
|
|
381
345
|
* A reference to a transaction.
|
|
382
346
|
* The `Transaction` object passed to a transaction's updateFunction provides
|
|
383
347
|
* the methods to read and write data within the transaction context. See
|
|
384
348
|
* `Firestore.runTransaction()`.
|
|
385
349
|
*/
|
|
386
|
-
export class Transaction {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
* to update, optionally followed by a `Precondition` to enforce on this
|
|
485
|
-
* update.
|
|
486
|
-
* @return This `Transaction` instance. Used for chaining method calls.
|
|
487
|
-
*/
|
|
488
|
-
update(
|
|
489
|
-
documentRef: DocumentReference<any>,
|
|
490
|
-
field: string | FieldPath,
|
|
491
|
-
value: any,
|
|
492
|
-
...fieldsOrPrecondition: any[]
|
|
493
|
-
): Transaction;
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Deletes the document referred to by the provided `DocumentReference`.
|
|
497
|
-
*
|
|
498
|
-
* @param documentRef A reference to the document to be deleted.
|
|
499
|
-
* @param precondition A Precondition to enforce for this delete.
|
|
500
|
-
* @return This `Transaction` instance. Used for chaining method calls.
|
|
501
|
-
*/
|
|
502
|
-
delete(documentRef: DocumentReference<any>, precondition?: Precondition): Transaction;
|
|
350
|
+
export declare class Transaction {
|
|
351
|
+
private constructor();
|
|
352
|
+
/**
|
|
353
|
+
* Retrieves a query result. Holds a pessimistic lock on all returned
|
|
354
|
+
* documents.
|
|
355
|
+
*
|
|
356
|
+
* @param query A query to execute.
|
|
357
|
+
* @return A QuerySnapshot for the retrieved data.
|
|
358
|
+
*/
|
|
359
|
+
get<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
|
360
|
+
/**
|
|
361
|
+
* Reads the document referenced by the provided `DocumentReference.`
|
|
362
|
+
* Holds a pessimistic lock on the returned document.
|
|
363
|
+
*
|
|
364
|
+
* @param documentRef A reference to the document to be read.
|
|
365
|
+
* @return A DocumentSnapshot for the read data.
|
|
366
|
+
*/
|
|
367
|
+
get<T>(documentRef: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
|
368
|
+
/**
|
|
369
|
+
* Retrieves multiple documents from Firestore. Holds a pessimistic lock on
|
|
370
|
+
* all returned documents.
|
|
371
|
+
*
|
|
372
|
+
* The first argument is required and must be of type `DocumentReference`
|
|
373
|
+
* followed by any additional `DocumentReference` documents. If used, the
|
|
374
|
+
* optional `ReadOptions` must be the last argument.
|
|
375
|
+
*
|
|
376
|
+
* @param {Array.<DocumentReference|ReadOptions>} documentRefsOrReadOptions
|
|
377
|
+
* The `DocumentReferences` to receive, followed by an optional field
|
|
378
|
+
* mask.
|
|
379
|
+
* @return A Promise that resolves with an array of resulting document
|
|
380
|
+
* snapshots.
|
|
381
|
+
*/
|
|
382
|
+
getAll<T>(...documentRefsOrReadOptions: Array<DocumentReference<T> | ReadOptions>): Promise<Array<DocumentSnapshot<T>>>;
|
|
383
|
+
/**
|
|
384
|
+
* Create the document referred to by the provided `DocumentReference`.
|
|
385
|
+
* The operation will fail the transaction if a document exists at the
|
|
386
|
+
* specified location.
|
|
387
|
+
*
|
|
388
|
+
* @param documentRef A reference to the document to be create.
|
|
389
|
+
* @param data The object data to serialize as the document.
|
|
390
|
+
* @return This `Transaction` instance. Used for chaining method calls.
|
|
391
|
+
*/
|
|
392
|
+
create<T>(documentRef: DocumentReference<T>, data: T): Transaction;
|
|
393
|
+
/**
|
|
394
|
+
* Writes to the document referred to by the provided `DocumentReference`.
|
|
395
|
+
* If the document does not exist yet, it will be created. If you pass
|
|
396
|
+
* `SetOptions`, the provided data can be merged into the existing document.
|
|
397
|
+
*
|
|
398
|
+
* @param documentRef A reference to the document to be set.
|
|
399
|
+
* @param data An object of the fields and values for the document.
|
|
400
|
+
* @param options An object to configure the set behavior.
|
|
401
|
+
* @return This `Transaction` instance. Used for chaining method calls.
|
|
402
|
+
*/
|
|
403
|
+
set<T>(documentRef: DocumentReference<T>, data: Partial<T>, options: SetOptions): Transaction;
|
|
404
|
+
set<T>(documentRef: DocumentReference<T>, data: T): Transaction;
|
|
405
|
+
/**
|
|
406
|
+
* Updates fields in the document referred to by the provided
|
|
407
|
+
* `DocumentReference`. The update will fail if applied to a document that
|
|
408
|
+
* does not exist.
|
|
409
|
+
*
|
|
410
|
+
* Nested fields can be updated by providing dot-separated field path
|
|
411
|
+
* strings.
|
|
412
|
+
*
|
|
413
|
+
* @param documentRef A reference to the document to be updated.
|
|
414
|
+
* @param data An object containing the fields and values with which to
|
|
415
|
+
* update the document.
|
|
416
|
+
* @param precondition A Precondition to enforce on this update.
|
|
417
|
+
* @return This `Transaction` instance. Used for chaining method calls.
|
|
418
|
+
*/
|
|
419
|
+
update(documentRef: DocumentReference<any>, data: UpdateData, precondition?: Precondition): Transaction;
|
|
420
|
+
/**
|
|
421
|
+
* Updates fields in the document referred to by the provided
|
|
422
|
+
* `DocumentReference`. The update will fail if applied to a document that
|
|
423
|
+
* does not exist.
|
|
424
|
+
*
|
|
425
|
+
* Nested fields can be updated by providing dot-separated field path
|
|
426
|
+
* strings or by providing FieldPath objects.
|
|
427
|
+
*
|
|
428
|
+
* A `Precondition` restricting this update can be specified as the last
|
|
429
|
+
* argument.
|
|
430
|
+
*
|
|
431
|
+
* @param documentRef A reference to the document to be updated.
|
|
432
|
+
* @param field The first field to update.
|
|
433
|
+
* @param value The first value
|
|
434
|
+
* @param fieldsOrPrecondition An alternating list of field paths and values
|
|
435
|
+
* to update, optionally followed by a `Precondition` to enforce on this
|
|
436
|
+
* update.
|
|
437
|
+
* @return This `Transaction` instance. Used for chaining method calls.
|
|
438
|
+
*/
|
|
439
|
+
update(documentRef: DocumentReference<any>, field: string | FieldPath, value: any, ...fieldsOrPrecondition: any[]): Transaction;
|
|
440
|
+
/**
|
|
441
|
+
* Deletes the document referred to by the provided `DocumentReference`.
|
|
442
|
+
*
|
|
443
|
+
* @param documentRef A reference to the document to be deleted.
|
|
444
|
+
* @param precondition A Precondition to enforce for this delete.
|
|
445
|
+
* @return This `Transaction` instance. Used for chaining method calls.
|
|
446
|
+
*/
|
|
447
|
+
delete(documentRef: DocumentReference<any>, precondition?: Precondition): Transaction;
|
|
503
448
|
}
|
|
504
|
-
|
|
505
449
|
/**
|
|
506
450
|
* A Firestore BulkWriter than can be used to perform a large number of writes
|
|
507
451
|
* in parallel. Writes to the same document will be executed sequentially.
|
|
508
452
|
*
|
|
509
453
|
* @class
|
|
510
454
|
*/
|
|
511
|
-
export class BulkWriter {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
* does not wait for writes that were added after the method is called. If
|
|
668
|
-
* you want to wait for additional writes, call `flush()` again.
|
|
669
|
-
*
|
|
670
|
-
* @return A promise that resolves when all enqueued writes
|
|
671
|
-
* up to this point have been committed.
|
|
672
|
-
*/
|
|
673
|
-
flush(): Promise<void>;
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* Commits all enqueued writes and marks the BulkWriter instance as closed.
|
|
677
|
-
*
|
|
678
|
-
* After calling `close()`, calling any method will throw an error. Any
|
|
679
|
-
* retries scheduled as part of an `onWriteError()` handler will be run
|
|
680
|
-
* before the `close()` promise resolves.
|
|
681
|
-
*
|
|
682
|
-
* Returns a Promise that resolves when all writes have been committed. The
|
|
683
|
-
* Promise will never be rejected. Calling this method will send all
|
|
684
|
-
* requests. The promise resolves immediately if there are no pending
|
|
685
|
-
* writes.
|
|
686
|
-
*
|
|
687
|
-
* @return A promise that resolves when all enqueued writes
|
|
688
|
-
* up to this point have been committed.
|
|
689
|
-
*/
|
|
690
|
-
close(): Promise<void>;
|
|
455
|
+
export declare class BulkWriter {
|
|
456
|
+
private constructor();
|
|
457
|
+
/**
|
|
458
|
+
* Create a document with the provided data. This single operation will fail
|
|
459
|
+
* if a document exists at its location.
|
|
460
|
+
*
|
|
461
|
+
* @param documentRef A reference to the document to be
|
|
462
|
+
* created.
|
|
463
|
+
* @param data The object to serialize as the document.
|
|
464
|
+
* @returns A promise that resolves with the result of the write. If the
|
|
465
|
+
* write fails, the promise is rejected with a
|
|
466
|
+
* [BulkWriterError]{@link BulkWriterError}.
|
|
467
|
+
*/
|
|
468
|
+
create<T>(documentRef: DocumentReference<T>, data: T): Promise<WriteResult>;
|
|
469
|
+
/**
|
|
470
|
+
* Delete a document from the database.
|
|
471
|
+
*
|
|
472
|
+
* @param documentRef A reference to the document to be
|
|
473
|
+
* deleted.
|
|
474
|
+
* @param precondition A precondition to enforce for this
|
|
475
|
+
* delete.
|
|
476
|
+
* @param precondition.lastUpdateTime If set, enforces that the
|
|
477
|
+
* document was last updated at lastUpdateTime. Fails the batch if the
|
|
478
|
+
* document doesn't exist or was last updated at a different time.
|
|
479
|
+
* @param precondition.exists If set, enforces that the target document
|
|
480
|
+
* must or must not exist.
|
|
481
|
+
* @returns A promise that resolves with the result of the delete. If the
|
|
482
|
+
* delete fails, the promise is rejected with a
|
|
483
|
+
* [BulkWriterError]{@link BulkWriterError}.
|
|
484
|
+
*/
|
|
485
|
+
delete(documentRef: DocumentReference<any>, precondition?: Precondition): Promise<WriteResult>;
|
|
486
|
+
/**
|
|
487
|
+
* Write to the document referred to by the provided
|
|
488
|
+
* [DocumentReference]{@link DocumentReference}. If the document does not
|
|
489
|
+
* exist yet, it will be created. If you pass
|
|
490
|
+
* [SetOptions]{@link SetOptions}., the provided data can be merged into the
|
|
491
|
+
* existing document.
|
|
492
|
+
*
|
|
493
|
+
* @param documentRef A reference to the document to be
|
|
494
|
+
* set.
|
|
495
|
+
* @param data The object to serialize as the document.
|
|
496
|
+
* @param options An object to configure the set behavior.
|
|
497
|
+
* @param options.merge - If true, set() merges the values
|
|
498
|
+
* specified in its data argument. Fields omitted from this set() call
|
|
499
|
+
* remain untouched.
|
|
500
|
+
* @param options.mergeFields - If provided,
|
|
501
|
+
* set() only replaces the specified field paths. Any field path that is not
|
|
502
|
+
* specified is ignored and remains untouched.
|
|
503
|
+
* @returns A promise that resolves with the result of the write. If the
|
|
504
|
+
* write fails, the promise is rejected with a
|
|
505
|
+
* [BulkWriterError]{@link BulkWriterError}.
|
|
506
|
+
*/
|
|
507
|
+
set<T>(documentRef: DocumentReference<T>, data: Partial<T>, options: SetOptions): Promise<WriteResult>;
|
|
508
|
+
set<T>(documentRef: DocumentReference<T>, data: T): Promise<WriteResult>;
|
|
509
|
+
/**
|
|
510
|
+
* Update fields of the document referred to by the provided
|
|
511
|
+
* [DocumentReference]{@link DocumentReference}. If the document doesn't yet
|
|
512
|
+
* exist, the update fails and the entire batch will be rejected.
|
|
513
|
+
*
|
|
514
|
+
* The update() method accepts either an object with field paths encoded as
|
|
515
|
+
* keys and field values encoded as values, or a variable number of
|
|
516
|
+
* arguments that alternate between field paths and field values. Nested
|
|
517
|
+
* fields can be updated by providing dot-separated field path strings or by
|
|
518
|
+
* providing FieldPath objects.
|
|
519
|
+
*
|
|
520
|
+
*
|
|
521
|
+
* A Precondition restricting this update can be specified as the last
|
|
522
|
+
* argument.
|
|
523
|
+
*
|
|
524
|
+
* @param documentRef A reference to the document to be updated.
|
|
525
|
+
* @param data An object containing the fields and values with which to
|
|
526
|
+
* update the document.
|
|
527
|
+
* @param precondition A Precondition to enforce on this update.
|
|
528
|
+
* @returns A promise that resolves with the result of the write. If the
|
|
529
|
+
* write fails, the promise is rejected with a
|
|
530
|
+
* [BulkWriterError]{@link BulkWriterError}.
|
|
531
|
+
*/
|
|
532
|
+
update(documentRef: DocumentReference<any>, data: UpdateData, precondition?: Precondition): Promise<WriteResult>;
|
|
533
|
+
/**
|
|
534
|
+
* Update fields of the document referred to by the provided
|
|
535
|
+
* [DocumentReference]{@link DocumentReference}. If the document doesn't yet
|
|
536
|
+
* exist, the update fails and the entire batch will be rejected.
|
|
537
|
+
*
|
|
538
|
+
* The update() method accepts either an object with field paths encoded as
|
|
539
|
+
* keys and field values encoded as values, or a variable number of
|
|
540
|
+
* arguments that alternate between field paths and field values. Nested
|
|
541
|
+
* fields can be updated by providing dot-separated field path strings or by
|
|
542
|
+
* providing FieldPath objects.
|
|
543
|
+
*
|
|
544
|
+
*
|
|
545
|
+
* A Precondition restricting this update can be specified as the last
|
|
546
|
+
* argument.
|
|
547
|
+
*
|
|
548
|
+
* @param documentRef A reference to the document to be updated.
|
|
549
|
+
* @param field The first field to update.
|
|
550
|
+
* @param value The first value
|
|
551
|
+
* @param fieldsOrPrecondition An alternating list of field paths and values
|
|
552
|
+
* to update, optionally followed a `Precondition` to enforce on this update.
|
|
553
|
+
* @returns A promise that resolves with the result of the write. If the
|
|
554
|
+
* write fails, the promise is rejected with a
|
|
555
|
+
* [BulkWriterError]{@link BulkWriterError}.
|
|
556
|
+
*/
|
|
557
|
+
update(documentRef: DocumentReference<any>, field: string | FieldPath, value: any, ...fieldsOrPrecondition: any[]): Promise<WriteResult>;
|
|
558
|
+
/**
|
|
559
|
+
* Attaches a listener that is run every time a BulkWriter operation
|
|
560
|
+
* successfully completes.
|
|
561
|
+
*
|
|
562
|
+
* @param callback A callback to be called every time a BulkWriter operation
|
|
563
|
+
* successfully completes.
|
|
564
|
+
*/
|
|
565
|
+
onWriteResult(callback: (documentRef: DocumentReference<any>, result: WriteResult) => void): void;
|
|
566
|
+
/**
|
|
567
|
+
* Attaches an error handler listener that is run every time a BulkWriter
|
|
568
|
+
* operation fails.
|
|
569
|
+
*
|
|
570
|
+
* BulkWriter has a default error handler that retries UNAVAILABLE and
|
|
571
|
+
* ABORTED errors up to a maximum of 10 failed attempts. When an error
|
|
572
|
+
* handler is specified, the default error handler will be overwritten.
|
|
573
|
+
*
|
|
574
|
+
* @param shouldRetryCallback A callback to be called every time a BulkWriter
|
|
575
|
+
* operation fails. Returning `true` will retry the operation. Returning
|
|
576
|
+
* `false` will stop the retry loop.
|
|
577
|
+
*/
|
|
578
|
+
onWriteError(shouldRetryCallback: (error: BulkWriterError) => boolean): void;
|
|
579
|
+
/**
|
|
580
|
+
* Commits all writes that have been enqueued up to this point in parallel.
|
|
581
|
+
*
|
|
582
|
+
* Returns a Promise that resolves when all currently queued operations have
|
|
583
|
+
* been committed. The Promise will never be rejected since the results for
|
|
584
|
+
* each individual operation are conveyed via their individual Promises.
|
|
585
|
+
*
|
|
586
|
+
* The Promise resolves immediately if there are no pending writes.
|
|
587
|
+
* Otherwise, the Promise waits for all previously issued writes, but it
|
|
588
|
+
* does not wait for writes that were added after the method is called. If
|
|
589
|
+
* you want to wait for additional writes, call `flush()` again.
|
|
590
|
+
*
|
|
591
|
+
* @return A promise that resolves when all enqueued writes
|
|
592
|
+
* up to this point have been committed.
|
|
593
|
+
*/
|
|
594
|
+
flush(): Promise<void>;
|
|
595
|
+
/**
|
|
596
|
+
* Commits all enqueued writes and marks the BulkWriter instance as closed.
|
|
597
|
+
*
|
|
598
|
+
* After calling `close()`, calling any method will throw an error. Any
|
|
599
|
+
* retries scheduled as part of an `onWriteError()` handler will be run
|
|
600
|
+
* before the `close()` promise resolves.
|
|
601
|
+
*
|
|
602
|
+
* Returns a Promise that resolves when all writes have been committed. The
|
|
603
|
+
* Promise will never be rejected. Calling this method will send all
|
|
604
|
+
* requests. The promise resolves immediately if there are no pending
|
|
605
|
+
* writes.
|
|
606
|
+
*
|
|
607
|
+
* @return A promise that resolves when all enqueued writes
|
|
608
|
+
* up to this point have been committed.
|
|
609
|
+
*/
|
|
610
|
+
close(): Promise<void>;
|
|
691
611
|
}
|
|
692
|
-
|
|
693
612
|
/**
|
|
694
613
|
* An options object to configure throttling on BulkWriter.
|
|
695
614
|
*/
|
|
696
615
|
export interface BulkWriterOptions {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
616
|
+
/**
|
|
617
|
+
* Whether to disable or configure throttling. By default, throttling is
|
|
618
|
+
* enabled. This field can be set to either a boolean or a config
|
|
619
|
+
* object. Setting it to `true` will use default values. You can override
|
|
620
|
+
* the defaults by setting it to `false` to disable throttling, or by
|
|
621
|
+
* setting the config values to enable throttling with the provided values.
|
|
622
|
+
*
|
|
623
|
+
* @see https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic
|
|
624
|
+
*
|
|
625
|
+
* @param initialOpsPerSecond The initial maximum number of operations per
|
|
626
|
+
* second allowed by the throttler. If this field is not set, the default
|
|
627
|
+
* is 500 operations per second.
|
|
628
|
+
* @param maxOpsPerSecond The maximum number of operations per second
|
|
629
|
+
* allowed by the throttler. If this field is set, the throttler's allowed
|
|
630
|
+
* operations per second does not ramp up past the specified operations per
|
|
631
|
+
* second.
|
|
632
|
+
*/
|
|
633
|
+
readonly throttling?: boolean | {
|
|
634
|
+
initialOpsPerSecond?: number;
|
|
635
|
+
maxOpsPerSecond?: number;
|
|
636
|
+
};
|
|
715
637
|
}
|
|
716
|
-
|
|
717
638
|
/**
|
|
718
639
|
* The error thrown when a BulkWriter operation fails.
|
|
719
640
|
*/
|
|
720
|
-
export class BulkWriterError extends Error {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
readonly operationType: 'create' | 'set' | 'update' | 'delete';
|
|
732
|
-
|
|
733
|
-
/** How many times this operation has been attempted unsuccessfully. */
|
|
734
|
-
readonly failedAttempts: number;
|
|
641
|
+
export declare class BulkWriterError extends Error {
|
|
642
|
+
/** The status code of the error. */
|
|
643
|
+
readonly code: GrpcStatus;
|
|
644
|
+
/** The error message of the error. */
|
|
645
|
+
readonly message: string;
|
|
646
|
+
/** The document reference the operation was performed on. */
|
|
647
|
+
readonly documentRef: DocumentReference<any>;
|
|
648
|
+
/** The type of operation performed. */
|
|
649
|
+
readonly operationType: 'create' | 'set' | 'update' | 'delete';
|
|
650
|
+
/** How many times this operation has been attempted unsuccessfully. */
|
|
651
|
+
readonly failedAttempts: number;
|
|
735
652
|
}
|
|
736
|
-
|
|
737
653
|
/**
|
|
738
654
|
* A write batch, used to perform multiple writes as a single atomic unit.
|
|
739
655
|
*
|
|
@@ -745,96 +661,80 @@ export class BulkWriterError extends Error {
|
|
|
745
661
|
* Unlike transactions, write batches are persisted offline and therefore are
|
|
746
662
|
* preferable when you don't need to condition your writes on read data.
|
|
747
663
|
*/
|
|
748
|
-
export class WriteBatch {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
* Deletes the document referred to by the provided `DocumentReference`.
|
|
822
|
-
*
|
|
823
|
-
* @param documentRef A reference to the document to be deleted.
|
|
824
|
-
* @param precondition A Precondition to enforce for this delete.
|
|
825
|
-
* @return This `WriteBatch` instance. Used for chaining method calls.
|
|
826
|
-
*/
|
|
827
|
-
delete(documentRef: DocumentReference<any>, precondition?: Precondition): WriteBatch;
|
|
828
|
-
|
|
829
|
-
/**
|
|
830
|
-
* Commits all of the writes in this write batch as a single atomic unit.
|
|
831
|
-
*
|
|
832
|
-
* @return A Promise resolved once all of the writes in the batch have been
|
|
833
|
-
* successfully written to the backend as an atomic unit.
|
|
834
|
-
*/
|
|
835
|
-
commit(): Promise<WriteResult[]>;
|
|
664
|
+
export declare class WriteBatch {
|
|
665
|
+
private constructor();
|
|
666
|
+
/**
|
|
667
|
+
* Create the document referred to by the provided `DocumentReference`. The
|
|
668
|
+
* operation will fail the batch if a document exists at the specified
|
|
669
|
+
* location.
|
|
670
|
+
*
|
|
671
|
+
* @param documentRef A reference to the document to be created.
|
|
672
|
+
* @param data The object data to serialize as the document.
|
|
673
|
+
* @return This `WriteBatch` instance. Used for chaining method calls.
|
|
674
|
+
*/
|
|
675
|
+
create<T>(documentRef: DocumentReference<T>, data: T): WriteBatch;
|
|
676
|
+
/**
|
|
677
|
+
* Write to the document referred to by the provided `DocumentReference`.
|
|
678
|
+
* If the document does not exist yet, it will be created. If you pass
|
|
679
|
+
* `SetOptions`, the provided data can be merged into the existing document.
|
|
680
|
+
*
|
|
681
|
+
* @param documentRef A reference to the document to be set.
|
|
682
|
+
* @param data An object of the fields and values for the document.
|
|
683
|
+
* @param options An object to configure the set behavior.
|
|
684
|
+
* @return This `WriteBatch` instance. Used for chaining method calls.
|
|
685
|
+
*/
|
|
686
|
+
set<T>(documentRef: DocumentReference<T>, data: Partial<T>, options: SetOptions): WriteBatch;
|
|
687
|
+
set<T>(documentRef: DocumentReference<T>, data: T): WriteBatch;
|
|
688
|
+
/**
|
|
689
|
+
* Update fields of the document referred to by the provided
|
|
690
|
+
* `DocumentReference`. If the document doesn't yet exist, the update fails
|
|
691
|
+
* and the entire batch will be rejected.
|
|
692
|
+
*
|
|
693
|
+
* Nested fields can be updated by providing dot-separated field path
|
|
694
|
+
* strings.
|
|
695
|
+
*
|
|
696
|
+
* @param documentRef A reference to the document to be updated.
|
|
697
|
+
* @param data An object containing the fields and values with which to
|
|
698
|
+
* update the document.
|
|
699
|
+
* @param precondition A Precondition to enforce on this update.
|
|
700
|
+
* @return This `WriteBatch` instance. Used for chaining method calls.
|
|
701
|
+
*/
|
|
702
|
+
update(documentRef: DocumentReference<any>, data: UpdateData, precondition?: Precondition): WriteBatch;
|
|
703
|
+
/**
|
|
704
|
+
* Updates fields in the document referred to by the provided
|
|
705
|
+
* `DocumentReference`. The update will fail if applied to a document that
|
|
706
|
+
* does not exist.
|
|
707
|
+
*
|
|
708
|
+
* Nested fields can be updated by providing dot-separated field path
|
|
709
|
+
* strings or by providing FieldPath objects.
|
|
710
|
+
*
|
|
711
|
+
* A `Precondition` restricting this update can be specified as the last
|
|
712
|
+
* argument.
|
|
713
|
+
*
|
|
714
|
+
* @param documentRef A reference to the document to be updated.
|
|
715
|
+
* @param field The first field to update.
|
|
716
|
+
* @param value The first value
|
|
717
|
+
* @param fieldsOrPrecondition An alternating list of field paths and values
|
|
718
|
+
* to update, optionally followed a `Precondition` to enforce on this update.
|
|
719
|
+
* @return This `WriteBatch` instance. Used for chaining method calls.
|
|
720
|
+
*/
|
|
721
|
+
update(documentRef: DocumentReference<any>, field: string | FieldPath, value: any, ...fieldsOrPrecondition: any[]): WriteBatch;
|
|
722
|
+
/**
|
|
723
|
+
* Deletes the document referred to by the provided `DocumentReference`.
|
|
724
|
+
*
|
|
725
|
+
* @param documentRef A reference to the document to be deleted.
|
|
726
|
+
* @param precondition A Precondition to enforce for this delete.
|
|
727
|
+
* @return This `WriteBatch` instance. Used for chaining method calls.
|
|
728
|
+
*/
|
|
729
|
+
delete(documentRef: DocumentReference<any>, precondition?: Precondition): WriteBatch;
|
|
730
|
+
/**
|
|
731
|
+
* Commits all of the writes in this write batch as a single atomic unit.
|
|
732
|
+
*
|
|
733
|
+
* @return A Promise resolved once all of the writes in the batch have been
|
|
734
|
+
* successfully written to the backend as an atomic unit.
|
|
735
|
+
*/
|
|
736
|
+
commit(): Promise<WriteResult[]>;
|
|
836
737
|
}
|
|
837
|
-
|
|
838
738
|
/**
|
|
839
739
|
* An options object that configures conditional behavior of `update()` and
|
|
840
740
|
* `delete()` calls in `DocumentReference`, `WriteBatch`, and `Transaction`.
|
|
@@ -842,17 +742,15 @@ export class WriteBatch {
|
|
|
842
742
|
* documents that match the specified restrictions.
|
|
843
743
|
*/
|
|
844
744
|
export interface Precondition {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
readonly exists?: boolean;
|
|
745
|
+
/**
|
|
746
|
+
* If set, the last update time to enforce.
|
|
747
|
+
*/
|
|
748
|
+
readonly lastUpdateTime?: Timestamp;
|
|
749
|
+
/**
|
|
750
|
+
* If set, enforces that the target document must or must not exist.
|
|
751
|
+
*/
|
|
752
|
+
readonly exists?: boolean;
|
|
854
753
|
}
|
|
855
|
-
|
|
856
754
|
/**
|
|
857
755
|
* An options object that configures the behavior of `set()` calls in
|
|
858
756
|
* `DocumentReference`, `WriteBatch` and `Transaction`. These calls can be
|
|
@@ -860,219 +758,190 @@ export interface Precondition {
|
|
|
860
758
|
* documents in their entirety.
|
|
861
759
|
*/
|
|
862
760
|
export interface SetOptions {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
readonly mergeFields?: (string | FieldPath)[];
|
|
761
|
+
/**
|
|
762
|
+
* Changes the behavior of a set() call to only replace the values specified
|
|
763
|
+
* in its data argument. Fields omitted from the set() call remain
|
|
764
|
+
* untouched.
|
|
765
|
+
*/
|
|
766
|
+
readonly merge?: boolean;
|
|
767
|
+
/**
|
|
768
|
+
* Changes the behavior of set() calls to only replace the specified field
|
|
769
|
+
* paths. Any field path that is not specified is ignored and remains
|
|
770
|
+
* untouched.
|
|
771
|
+
*
|
|
772
|
+
* It is an error to pass a SetOptions object to a set() call that is
|
|
773
|
+
* missing a value for any of the fields specified here.
|
|
774
|
+
*/
|
|
775
|
+
readonly mergeFields?: (string | FieldPath)[];
|
|
879
776
|
}
|
|
880
|
-
|
|
881
777
|
/**
|
|
882
778
|
* An options object that can be used to configure the behavior of `getAll()`
|
|
883
779
|
* calls. By providing a `fieldMask`, these calls can be configured to only
|
|
884
780
|
* return a subset of fields.
|
|
885
781
|
*/
|
|
886
782
|
export interface ReadOptions {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
783
|
+
/**
|
|
784
|
+
* Specifies the set of fields to return and reduces the amount of data
|
|
785
|
+
* transmitted by the backend.
|
|
786
|
+
*
|
|
787
|
+
* Adding a field mask does not filter results. Documents do not need to
|
|
788
|
+
* contain values for all the fields in the mask to be part of the result
|
|
789
|
+
* set.
|
|
790
|
+
*/
|
|
791
|
+
readonly fieldMask?: (string | FieldPath)[];
|
|
896
792
|
}
|
|
897
|
-
|
|
898
793
|
/**
|
|
899
794
|
* A WriteResult wraps the write time set by the Firestore servers on `sets()`,
|
|
900
795
|
* `updates()`, and `creates()`.
|
|
901
796
|
*/
|
|
902
|
-
export class WriteResult {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
*/
|
|
916
|
-
isEqual(other: WriteResult): boolean;
|
|
797
|
+
export declare class WriteResult {
|
|
798
|
+
private constructor();
|
|
799
|
+
/**
|
|
800
|
+
* The write time as set by the Firestore servers.
|
|
801
|
+
*/
|
|
802
|
+
readonly writeTime: Timestamp;
|
|
803
|
+
/**
|
|
804
|
+
* Returns true if this `WriteResult` is equal to the provided one.
|
|
805
|
+
*
|
|
806
|
+
* @param other The `WriteResult` to compare against.
|
|
807
|
+
* @return true if this `WriteResult` is equal to the provided one.
|
|
808
|
+
*/
|
|
809
|
+
isEqual(other: WriteResult): boolean;
|
|
917
810
|
}
|
|
918
|
-
|
|
919
811
|
/**
|
|
920
812
|
* A `DocumentReference` refers to a document location in a Firestore database
|
|
921
813
|
* and can be used to write, read, or listen to the location. The document at
|
|
922
814
|
* the referenced location may or may not exist. A `DocumentReference` can
|
|
923
815
|
* also be used to create a `CollectionReference` to a subcollection.
|
|
924
816
|
*/
|
|
925
|
-
export class DocumentReference<T = DocumentData> {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* Returns true if this `DocumentReference` is equal to the provided one.
|
|
1055
|
-
*
|
|
1056
|
-
* @param other The `DocumentReference` to compare against.
|
|
1057
|
-
* @return true if this `DocumentReference` is equal to the provided one.
|
|
1058
|
-
*/
|
|
1059
|
-
isEqual(other: DocumentReference<T>): boolean;
|
|
1060
|
-
|
|
1061
|
-
/**
|
|
1062
|
-
* Applies a custom data converter to this DocumentReference, allowing you
|
|
1063
|
-
* to use your own custom model objects with Firestore. When you call
|
|
1064
|
-
* set(), get(), etc. on the returned DocumentReference instance, the
|
|
1065
|
-
* provided converter will convert between Firestore data and your custom
|
|
1066
|
-
* type U.
|
|
1067
|
-
*
|
|
1068
|
-
* @param converter Converts objects to and from Firestore. Passing in
|
|
1069
|
-
* `null` removes the current converter.
|
|
1070
|
-
* @return A DocumentReference<U> that uses the provided converter.
|
|
1071
|
-
*/
|
|
1072
|
-
withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
|
|
1073
|
-
withConverter(converter: null): DocumentReference<DocumentData>;
|
|
817
|
+
export declare class DocumentReference<T = DocumentData> {
|
|
818
|
+
private constructor();
|
|
819
|
+
/** The identifier of the document within its collection. */
|
|
820
|
+
readonly id: string;
|
|
821
|
+
/**
|
|
822
|
+
* The `Firestore` for the Firestore database (useful for performing
|
|
823
|
+
* transactions, etc.).
|
|
824
|
+
*/
|
|
825
|
+
readonly firestore: Firestore;
|
|
826
|
+
/**
|
|
827
|
+
* A reference to the Collection to which this DocumentReference belongs.
|
|
828
|
+
*/
|
|
829
|
+
readonly parent: CollectionReference<T>;
|
|
830
|
+
/**
|
|
831
|
+
* A string representing the path of the referenced document (relative
|
|
832
|
+
* to the root of the database).
|
|
833
|
+
*/
|
|
834
|
+
readonly path: string;
|
|
835
|
+
/**
|
|
836
|
+
* Gets a `CollectionReference` instance that refers to the collection at
|
|
837
|
+
* the specified path.
|
|
838
|
+
*
|
|
839
|
+
* @param collectionPath A slash-separated path to a collection.
|
|
840
|
+
* @return The `CollectionReference` instance.
|
|
841
|
+
*/
|
|
842
|
+
collection(collectionPath: string): CollectionReference<DocumentData>;
|
|
843
|
+
/**
|
|
844
|
+
* Fetches the subcollections that are direct children of this document.
|
|
845
|
+
*
|
|
846
|
+
* @returns A Promise that resolves with an array of CollectionReferences.
|
|
847
|
+
*/
|
|
848
|
+
listCollections(): Promise<Array<CollectionReference<DocumentData>>>;
|
|
849
|
+
/**
|
|
850
|
+
* Creates a document referred to by this `DocumentReference` with the
|
|
851
|
+
* provided object values. The write fails if the document already exists
|
|
852
|
+
*
|
|
853
|
+
* @param data The object data to serialize as the document.
|
|
854
|
+
* @return A Promise resolved with the write time of this create.
|
|
855
|
+
*/
|
|
856
|
+
create(data: T): Promise<WriteResult>;
|
|
857
|
+
/**
|
|
858
|
+
* Writes to the document referred to by this `DocumentReference`. If the
|
|
859
|
+
* document does not yet exist, it will be created. If you pass
|
|
860
|
+
* `SetOptions`, the provided data can be merged into an existing document.
|
|
861
|
+
*
|
|
862
|
+
* @param data A map of the fields and values for the document.
|
|
863
|
+
* @param options An object to configure the set behavior.
|
|
864
|
+
* @return A Promise resolved with the write time of this set.
|
|
865
|
+
*/
|
|
866
|
+
set(data: Partial<T>, options: SetOptions): Promise<WriteResult>;
|
|
867
|
+
set(data: T): Promise<WriteResult>;
|
|
868
|
+
/**
|
|
869
|
+
* Updates fields in the document referred to by this `DocumentReference`.
|
|
870
|
+
* The update will fail if applied to a document that does not exist.
|
|
871
|
+
*
|
|
872
|
+
* Nested fields can be updated by providing dot-separated field path
|
|
873
|
+
* strings.
|
|
874
|
+
*
|
|
875
|
+
* @param data An object containing the fields and values with which to
|
|
876
|
+
* update the document.
|
|
877
|
+
* @param precondition A Precondition to enforce on this update.
|
|
878
|
+
* @return A Promise resolved with the write time of this update.
|
|
879
|
+
*/
|
|
880
|
+
update(data: UpdateData, precondition?: Precondition): Promise<WriteResult>;
|
|
881
|
+
/**
|
|
882
|
+
* Updates fields in the document referred to by this `DocumentReference`.
|
|
883
|
+
* The update will fail if applied to a document that does not exist.
|
|
884
|
+
*
|
|
885
|
+
* Nested fields can be updated by providing dot-separated field path
|
|
886
|
+
* strings or by providing FieldPath objects.
|
|
887
|
+
*
|
|
888
|
+
* A `Precondition` restricting this update can be specified as the last
|
|
889
|
+
* argument.
|
|
890
|
+
*
|
|
891
|
+
* @param field The first field to update.
|
|
892
|
+
* @param value The first value.
|
|
893
|
+
* @param moreFieldsOrPrecondition An alternating list of field paths and
|
|
894
|
+
* values to update, optionally followed by a `Precondition` to enforce on
|
|
895
|
+
* this update.
|
|
896
|
+
* @return A Promise resolved with the write time of this update.
|
|
897
|
+
*/
|
|
898
|
+
update(field: string | FieldPath, value: any, ...moreFieldsOrPrecondition: any[]): Promise<WriteResult>;
|
|
899
|
+
/**
|
|
900
|
+
* Deletes the document referred to by this `DocumentReference`.
|
|
901
|
+
*
|
|
902
|
+
* @param precondition A Precondition to enforce for this delete.
|
|
903
|
+
* @return A Promise resolved with the write time of this delete.
|
|
904
|
+
*/
|
|
905
|
+
delete(precondition?: Precondition): Promise<WriteResult>;
|
|
906
|
+
/**
|
|
907
|
+
* Reads the document referred to by this `DocumentReference`.
|
|
908
|
+
*
|
|
909
|
+
* @return A Promise resolved with a DocumentSnapshot containing the
|
|
910
|
+
* current document contents.
|
|
911
|
+
*/
|
|
912
|
+
get(): Promise<DocumentSnapshot<T>>;
|
|
913
|
+
/**
|
|
914
|
+
* Attaches a listener for DocumentSnapshot events.
|
|
915
|
+
*
|
|
916
|
+
* @param onNext A callback to be called every time a new `DocumentSnapshot`
|
|
917
|
+
* is available.
|
|
918
|
+
* @param onError A callback to be called if the listen fails or is
|
|
919
|
+
* cancelled. No further callbacks will occur.
|
|
920
|
+
* @return An unsubscribe function that can be called to cancel
|
|
921
|
+
* the snapshot listener.
|
|
922
|
+
*/
|
|
923
|
+
onSnapshot(onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: Error) => void): () => void;
|
|
924
|
+
/**
|
|
925
|
+
* Returns true if this `DocumentReference` is equal to the provided one.
|
|
926
|
+
*
|
|
927
|
+
* @param other The `DocumentReference` to compare against.
|
|
928
|
+
* @return true if this `DocumentReference` is equal to the provided one.
|
|
929
|
+
*/
|
|
930
|
+
isEqual(other: DocumentReference<T>): boolean;
|
|
931
|
+
/**
|
|
932
|
+
* Applies a custom data converter to this DocumentReference, allowing you
|
|
933
|
+
* to use your own custom model objects with Firestore. When you call
|
|
934
|
+
* set(), get(), etc. on the returned DocumentReference instance, the
|
|
935
|
+
* provided converter will convert between Firestore data and your custom
|
|
936
|
+
* type U.
|
|
937
|
+
*
|
|
938
|
+
* @param converter Converts objects to and from Firestore. Passing in
|
|
939
|
+
* `null` removes the current converter.
|
|
940
|
+
* @return A DocumentReference<U> that uses the provided converter.
|
|
941
|
+
*/
|
|
942
|
+
withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
|
|
943
|
+
withConverter(converter: null): DocumentReference<DocumentData>;
|
|
1074
944
|
}
|
|
1075
|
-
|
|
1076
945
|
/**
|
|
1077
946
|
* A `DocumentSnapshot` contains data read from a document in your Firestore
|
|
1078
947
|
* database. The data can be extracted with `.data()` or `.get(<field>)` to
|
|
@@ -1082,64 +951,54 @@ export class DocumentReference<T = DocumentData> {
|
|
|
1082
951
|
* access will return 'undefined'. You can use the `exists` property to
|
|
1083
952
|
* explicitly verify a document's existence.
|
|
1084
953
|
*/
|
|
1085
|
-
export class DocumentSnapshot<T = DocumentData> {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
/**
|
|
1134
|
-
* Returns true if the document's data and path in this `DocumentSnapshot`
|
|
1135
|
-
* is equal to the provided one.
|
|
1136
|
-
*
|
|
1137
|
-
* @param other The `DocumentSnapshot` to compare against.
|
|
1138
|
-
* @return true if this `DocumentSnapshot` is equal to the provided one.
|
|
1139
|
-
*/
|
|
1140
|
-
isEqual(other: DocumentSnapshot<T>): boolean;
|
|
954
|
+
export declare class DocumentSnapshot<T = DocumentData> {
|
|
955
|
+
protected constructor();
|
|
956
|
+
/** True if the document exists. */
|
|
957
|
+
readonly exists: boolean;
|
|
958
|
+
/** A `DocumentReference` to the document location. */
|
|
959
|
+
readonly ref: DocumentReference<T>;
|
|
960
|
+
/**
|
|
961
|
+
* The ID of the document for which this `DocumentSnapshot` contains data.
|
|
962
|
+
*/
|
|
963
|
+
readonly id: string;
|
|
964
|
+
/**
|
|
965
|
+
* The time the document was created. Not set for documents that don't
|
|
966
|
+
* exist.
|
|
967
|
+
*/
|
|
968
|
+
readonly createTime?: Timestamp;
|
|
969
|
+
/**
|
|
970
|
+
* The time the document was last updated (at the time the snapshot was
|
|
971
|
+
* generated). Not set for documents that don't exist.
|
|
972
|
+
*/
|
|
973
|
+
readonly updateTime?: Timestamp;
|
|
974
|
+
/**
|
|
975
|
+
* The time this snapshot was read.
|
|
976
|
+
*/
|
|
977
|
+
readonly readTime: Timestamp;
|
|
978
|
+
/**
|
|
979
|
+
* Retrieves all fields in the document as an Object. Returns 'undefined' if
|
|
980
|
+
* the document doesn't exist.
|
|
981
|
+
*
|
|
982
|
+
* @return An Object containing all fields in the document.
|
|
983
|
+
*/
|
|
984
|
+
data(): T | undefined;
|
|
985
|
+
/**
|
|
986
|
+
* Retrieves the field specified by `fieldPath`.
|
|
987
|
+
*
|
|
988
|
+
* @param fieldPath The path (e.g. 'foo' or 'foo.bar') to a specific field.
|
|
989
|
+
* @return The data at the specified field location or undefined if no such
|
|
990
|
+
* field exists in the document.
|
|
991
|
+
*/
|
|
992
|
+
get(fieldPath: string | FieldPath): any;
|
|
993
|
+
/**
|
|
994
|
+
* Returns true if the document's data and path in this `DocumentSnapshot`
|
|
995
|
+
* is equal to the provided one.
|
|
996
|
+
*
|
|
997
|
+
* @param other The `DocumentSnapshot` to compare against.
|
|
998
|
+
* @return true if this `DocumentSnapshot` is equal to the provided one.
|
|
999
|
+
*/
|
|
1000
|
+
isEqual(other: DocumentSnapshot<T>): boolean;
|
|
1141
1001
|
}
|
|
1142
|
-
|
|
1143
1002
|
/**
|
|
1144
1003
|
* A `QueryDocumentSnapshot` contains data read from a document in your
|
|
1145
1004
|
* Firestore database as part of a query. The document is guaranteed to exist
|
|
@@ -1151,288 +1010,243 @@ export class DocumentSnapshot<T = DocumentData> {
|
|
|
1151
1010
|
* `exists` property will always be true and `data()` will never return
|
|
1152
1011
|
* 'undefined'.
|
|
1153
1012
|
*/
|
|
1154
|
-
export class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
* @return An Object containing all fields in the document.
|
|
1173
|
-
*/
|
|
1174
|
-
data(): T;
|
|
1013
|
+
export declare class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
|
|
1014
|
+
private constructor();
|
|
1015
|
+
/**
|
|
1016
|
+
* The time the document was created.
|
|
1017
|
+
*/
|
|
1018
|
+
readonly createTime: Timestamp;
|
|
1019
|
+
/**
|
|
1020
|
+
* The time the document was last updated (at the time the snapshot was
|
|
1021
|
+
* generated).
|
|
1022
|
+
*/
|
|
1023
|
+
readonly updateTime: Timestamp;
|
|
1024
|
+
/**
|
|
1025
|
+
* Retrieves all fields in the document as an Object.
|
|
1026
|
+
*
|
|
1027
|
+
* @override
|
|
1028
|
+
* @return An Object containing all fields in the document.
|
|
1029
|
+
*/
|
|
1030
|
+
data(): T;
|
|
1175
1031
|
}
|
|
1176
|
-
|
|
1177
1032
|
/**
|
|
1178
1033
|
* The direction of a `Query.orderBy()` clause is specified as 'desc' or 'asc'
|
|
1179
1034
|
* (descending or ascending).
|
|
1180
1035
|
*/
|
|
1181
1036
|
export type OrderByDirection = 'desc' | 'asc';
|
|
1182
|
-
|
|
1183
1037
|
/**
|
|
1184
1038
|
* Filter conditions in a `Query.where()` clause are specified using the
|
|
1185
1039
|
* strings '<', '<=', '==', '!=', '>=', '>', 'array-contains', 'in', 'not-in',
|
|
1186
1040
|
* and 'array-contains-any'.
|
|
1187
1041
|
*/
|
|
1188
|
-
export type WhereFilterOp =
|
|
1189
|
-
| '<'
|
|
1190
|
-
| '<='
|
|
1191
|
-
| '=='
|
|
1192
|
-
| '!='
|
|
1193
|
-
| '>='
|
|
1194
|
-
| '>'
|
|
1195
|
-
| 'array-contains'
|
|
1196
|
-
| 'in'
|
|
1197
|
-
| 'not-in'
|
|
1198
|
-
| 'array-contains-any';
|
|
1199
|
-
|
|
1042
|
+
export type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'not-in' | 'array-contains-any';
|
|
1200
1043
|
/**
|
|
1201
1044
|
* A `Query` refers to a Query which you can read or listen to. You can also
|
|
1202
1045
|
* construct refined `Query` objects by adding filters and ordering.
|
|
1203
1046
|
*/
|
|
1204
|
-
export class Query<T = DocumentData> {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
* @return An unsubscribe function that can be called to cancel
|
|
1407
|
-
* the snapshot listener.
|
|
1408
|
-
*/
|
|
1409
|
-
onSnapshot(
|
|
1410
|
-
onNext: (snapshot: QuerySnapshot<T>) => void,
|
|
1411
|
-
onError?: (error: Error) => void
|
|
1412
|
-
): () => void;
|
|
1413
|
-
|
|
1414
|
-
/**
|
|
1415
|
-
* Returns true if this `Query` is equal to the provided one.
|
|
1416
|
-
*
|
|
1417
|
-
* @param other The `Query` to compare against.
|
|
1418
|
-
* @return true if this `Query` is equal to the provided one.
|
|
1419
|
-
*/
|
|
1420
|
-
isEqual(other: Query<T>): boolean;
|
|
1421
|
-
|
|
1422
|
-
/**
|
|
1423
|
-
* Applies a custom data converter to this Query, allowing you to use your
|
|
1424
|
-
* own custom model objects with Firestore. When you call get() on the
|
|
1425
|
-
* returned Query, the provided converter will convert between Firestore
|
|
1426
|
-
* data and your custom type U.
|
|
1427
|
-
*
|
|
1428
|
-
* @param converter Converts objects to and from Firestore. Passing in
|
|
1429
|
-
* `null` removes the current converter.
|
|
1430
|
-
* @return A Query<U> that uses the provided converter.
|
|
1431
|
-
*/
|
|
1432
|
-
withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
|
|
1433
|
-
withConverter(converter: null): Query<DocumentData>;
|
|
1047
|
+
export declare class Query<T = DocumentData> {
|
|
1048
|
+
protected constructor();
|
|
1049
|
+
/**
|
|
1050
|
+
* The `Firestore` for the Firestore database (useful for performing
|
|
1051
|
+
* transactions, etc.).
|
|
1052
|
+
*/
|
|
1053
|
+
readonly firestore: Firestore;
|
|
1054
|
+
/**
|
|
1055
|
+
* Creates and returns a new Query with the additional filter that documents
|
|
1056
|
+
* must contain the specified field and that its value should satisfy the
|
|
1057
|
+
* relation constraint provided.
|
|
1058
|
+
*
|
|
1059
|
+
* This function returns a new (immutable) instance of the Query (rather
|
|
1060
|
+
* than modify the existing instance) to impose the filter.
|
|
1061
|
+
*
|
|
1062
|
+
* @param fieldPath The path to compare
|
|
1063
|
+
* @param opStr The operation string (e.g "<", "<=", "==", ">", ">=").
|
|
1064
|
+
* @param value The value for comparison
|
|
1065
|
+
* @return The created Query.
|
|
1066
|
+
*/
|
|
1067
|
+
where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: any): Query<T>;
|
|
1068
|
+
/**
|
|
1069
|
+
* Creates and returns a new Query that's additionally sorted by the
|
|
1070
|
+
* specified field, optionally in descending order instead of ascending.
|
|
1071
|
+
*
|
|
1072
|
+
* This function returns a new (immutable) instance of the Query (rather
|
|
1073
|
+
* than modify the existing instance) to impose the order.
|
|
1074
|
+
*
|
|
1075
|
+
* @param fieldPath The field to sort by.
|
|
1076
|
+
* @param directionStr Optional direction to sort by ('asc' or 'desc'). If
|
|
1077
|
+
* not specified, order will be ascending.
|
|
1078
|
+
* @return The created Query.
|
|
1079
|
+
*/
|
|
1080
|
+
orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): Query<T>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Creates and returns a new Query that only returns the first matching
|
|
1083
|
+
* documents.
|
|
1084
|
+
*
|
|
1085
|
+
* This function returns a new (immutable) instance of the Query (rather
|
|
1086
|
+
* than modify the existing instance) to impose the limit.
|
|
1087
|
+
*
|
|
1088
|
+
* @param limit The maximum number of items to return.
|
|
1089
|
+
* @return The created Query.
|
|
1090
|
+
*/
|
|
1091
|
+
limit(limit: number): Query<T>;
|
|
1092
|
+
/**
|
|
1093
|
+
* Creates and returns a new Query that only returns the last matching
|
|
1094
|
+
* documents.
|
|
1095
|
+
*
|
|
1096
|
+
* You must specify at least one orderBy clause for limitToLast queries,
|
|
1097
|
+
* otherwise an exception will be thrown during execution.
|
|
1098
|
+
*
|
|
1099
|
+
* Results for limitToLast queries cannot be streamed via the `stream()`
|
|
1100
|
+
* API.
|
|
1101
|
+
*
|
|
1102
|
+
* @param limit The maximum number of items to return.
|
|
1103
|
+
* @return The created Query.
|
|
1104
|
+
*/
|
|
1105
|
+
limitToLast(limit: number): Query<T>;
|
|
1106
|
+
/**
|
|
1107
|
+
* Specifies the offset of the returned results.
|
|
1108
|
+
*
|
|
1109
|
+
* This function returns a new (immutable) instance of the Query (rather
|
|
1110
|
+
* than modify the existing instance) to impose the offset.
|
|
1111
|
+
*
|
|
1112
|
+
* @param offset The offset to apply to the Query results.
|
|
1113
|
+
* @return The created Query.
|
|
1114
|
+
*/
|
|
1115
|
+
offset(offset: number): Query<T>;
|
|
1116
|
+
/**
|
|
1117
|
+
* Creates and returns a new Query instance that applies a field mask to
|
|
1118
|
+
* the result and returns only the specified subset of fields. You can
|
|
1119
|
+
* specify a list of field paths to return, or use an empty list to only
|
|
1120
|
+
* return the references of matching documents.
|
|
1121
|
+
*
|
|
1122
|
+
* Queries that contain field masks cannot be listened to via `onSnapshot()`
|
|
1123
|
+
* listeners.
|
|
1124
|
+
*
|
|
1125
|
+
* This function returns a new (immutable) instance of the Query (rather
|
|
1126
|
+
* than modify the existing instance) to impose the field mask.
|
|
1127
|
+
*
|
|
1128
|
+
* @param field The field paths to return.
|
|
1129
|
+
* @return The created Query.
|
|
1130
|
+
*/
|
|
1131
|
+
select(...field: (string | FieldPath)[]): Query<DocumentData>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Creates and returns a new Query that starts at the provided document
|
|
1134
|
+
* (inclusive). The starting position is relative to the order of the query.
|
|
1135
|
+
* The document must contain all of the fields provided in the orderBy of
|
|
1136
|
+
* this query.
|
|
1137
|
+
*
|
|
1138
|
+
* @param snapshot The snapshot of the document to start after.
|
|
1139
|
+
* @return The created Query.
|
|
1140
|
+
*/
|
|
1141
|
+
startAt(snapshot: DocumentSnapshot<any>): Query<T>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Creates and returns a new Query that starts at the provided fields
|
|
1144
|
+
* relative to the order of the query. The order of the field values
|
|
1145
|
+
* must match the order of the order by clauses of the query.
|
|
1146
|
+
*
|
|
1147
|
+
* @param fieldValues The field values to start this query at, in order
|
|
1148
|
+
* of the query's order by.
|
|
1149
|
+
* @return The created Query.
|
|
1150
|
+
*/
|
|
1151
|
+
startAt(...fieldValues: any[]): Query<T>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Creates and returns a new Query that starts after the provided document
|
|
1154
|
+
* (exclusive). The starting position is relative to the order of the query.
|
|
1155
|
+
* The document must contain all of the fields provided in the orderBy of
|
|
1156
|
+
* this query.
|
|
1157
|
+
*
|
|
1158
|
+
* @param snapshot The snapshot of the document to start after.
|
|
1159
|
+
* @return The created Query.
|
|
1160
|
+
*/
|
|
1161
|
+
startAfter(snapshot: DocumentSnapshot<any>): Query<T>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Creates and returns a new Query that starts after the provided fields
|
|
1164
|
+
* relative to the order of the query. The order of the field values
|
|
1165
|
+
* must match the order of the order by clauses of the query.
|
|
1166
|
+
*
|
|
1167
|
+
* @param fieldValues The field values to start this query after, in order
|
|
1168
|
+
* of the query's order by.
|
|
1169
|
+
* @return The created Query.
|
|
1170
|
+
*/
|
|
1171
|
+
startAfter(...fieldValues: any[]): Query<T>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Creates and returns a new Query that ends before the provided document
|
|
1174
|
+
* (exclusive). The end position is relative to the order of the query. The
|
|
1175
|
+
* document must contain all of the fields provided in the orderBy of this
|
|
1176
|
+
* query.
|
|
1177
|
+
*
|
|
1178
|
+
* @param snapshot The snapshot of the document to end before.
|
|
1179
|
+
* @return The created Query.
|
|
1180
|
+
*/
|
|
1181
|
+
endBefore(snapshot: DocumentSnapshot<any>): Query<T>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Creates and returns a new Query that ends before the provided fields
|
|
1184
|
+
* relative to the order of the query. The order of the field values
|
|
1185
|
+
* must match the order of the order by clauses of the query.
|
|
1186
|
+
*
|
|
1187
|
+
* @param fieldValues The field values to end this query before, in order
|
|
1188
|
+
* of the query's order by.
|
|
1189
|
+
* @return The created Query.
|
|
1190
|
+
*/
|
|
1191
|
+
endBefore(...fieldValues: any[]): Query<T>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Creates and returns a new Query that ends at the provided document
|
|
1194
|
+
* (inclusive). The end position is relative to the order of the query. The
|
|
1195
|
+
* document must contain all of the fields provided in the orderBy of this
|
|
1196
|
+
* query.
|
|
1197
|
+
*
|
|
1198
|
+
* @param snapshot The snapshot of the document to end at.
|
|
1199
|
+
* @return The created Query.
|
|
1200
|
+
*/
|
|
1201
|
+
endAt(snapshot: DocumentSnapshot<any>): Query<T>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Creates and returns a new Query that ends at the provided fields
|
|
1204
|
+
* relative to the order of the query. The order of the field values
|
|
1205
|
+
* must match the order of the order by clauses of the query.
|
|
1206
|
+
*
|
|
1207
|
+
* @param fieldValues The field values to end this query at, in order
|
|
1208
|
+
* of the query's order by.
|
|
1209
|
+
* @return The created Query.
|
|
1210
|
+
*/
|
|
1211
|
+
endAt(...fieldValues: any[]): Query<T>;
|
|
1212
|
+
/**
|
|
1213
|
+
* Executes the query and returns the results as a `QuerySnapshot`.
|
|
1214
|
+
*
|
|
1215
|
+
* @return A Promise that will be resolved with the results of the Query.
|
|
1216
|
+
*/
|
|
1217
|
+
get(): Promise<QuerySnapshot<T>>;
|
|
1218
|
+
stream(): NodeJS.ReadableStream;
|
|
1219
|
+
/**
|
|
1220
|
+
* Attaches a listener for `QuerySnapshot `events.
|
|
1221
|
+
*
|
|
1222
|
+
* @param onNext A callback to be called every time a new `QuerySnapshot`
|
|
1223
|
+
* is available.
|
|
1224
|
+
* @param onError A callback to be called if the listen fails or is
|
|
1225
|
+
* cancelled. No further callbacks will occur.
|
|
1226
|
+
* @return An unsubscribe function that can be called to cancel
|
|
1227
|
+
* the snapshot listener.
|
|
1228
|
+
*/
|
|
1229
|
+
onSnapshot(onNext: (snapshot: QuerySnapshot<T>) => void, onError?: (error: Error) => void): () => void;
|
|
1230
|
+
/**
|
|
1231
|
+
* Returns true if this `Query` is equal to the provided one.
|
|
1232
|
+
*
|
|
1233
|
+
* @param other The `Query` to compare against.
|
|
1234
|
+
* @return true if this `Query` is equal to the provided one.
|
|
1235
|
+
*/
|
|
1236
|
+
isEqual(other: Query<T>): boolean;
|
|
1237
|
+
/**
|
|
1238
|
+
* Applies a custom data converter to this Query, allowing you to use your
|
|
1239
|
+
* own custom model objects with Firestore. When you call get() on the
|
|
1240
|
+
* returned Query, the provided converter will convert between Firestore
|
|
1241
|
+
* data and your custom type U.
|
|
1242
|
+
*
|
|
1243
|
+
* @param converter Converts objects to and from Firestore. Passing in
|
|
1244
|
+
* `null` removes the current converter.
|
|
1245
|
+
* @return A Query<U> that uses the provided converter.
|
|
1246
|
+
*/
|
|
1247
|
+
withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
|
|
1248
|
+
withConverter(converter: null): Query<DocumentData>;
|
|
1434
1249
|
}
|
|
1435
|
-
|
|
1436
1250
|
/**
|
|
1437
1251
|
* A `QuerySnapshot` contains zero or more `QueryDocumentSnapshot` objects
|
|
1438
1252
|
* representing the results of a query. The documents can be accessed as an
|
|
@@ -1440,397 +1254,355 @@ export class Query<T = DocumentData> {
|
|
|
1440
1254
|
* number of documents can be determined via the `empty` and `size`
|
|
1441
1255
|
* properties.
|
|
1442
1256
|
*/
|
|
1443
|
-
export class QuerySnapshot<T = DocumentData> {
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
/**
|
|
1481
|
-
* Returns true if the document data in this `QuerySnapshot` is equal to the
|
|
1482
|
-
* provided one.
|
|
1483
|
-
*
|
|
1484
|
-
* @param other The `QuerySnapshot` to compare against.
|
|
1485
|
-
* @return true if this `QuerySnapshot` is equal to the provided one.
|
|
1486
|
-
*/
|
|
1487
|
-
isEqual(other: QuerySnapshot<T>): boolean;
|
|
1257
|
+
export declare class QuerySnapshot<T = DocumentData> {
|
|
1258
|
+
private constructor();
|
|
1259
|
+
/**
|
|
1260
|
+
* The query on which you called `get` or `onSnapshot` in order to get this
|
|
1261
|
+
* `QuerySnapshot`.
|
|
1262
|
+
*/
|
|
1263
|
+
readonly query: Query<T>;
|
|
1264
|
+
/** An array of all the documents in the QuerySnapshot. */
|
|
1265
|
+
readonly docs: Array<QueryDocumentSnapshot<T>>;
|
|
1266
|
+
/** The number of documents in the QuerySnapshot. */
|
|
1267
|
+
readonly size: number;
|
|
1268
|
+
/** True if there are no documents in the QuerySnapshot. */
|
|
1269
|
+
readonly empty: boolean;
|
|
1270
|
+
/** The time this query snapshot was obtained. */
|
|
1271
|
+
readonly readTime: Timestamp;
|
|
1272
|
+
/**
|
|
1273
|
+
* Returns an array of the documents changes since the last snapshot. If
|
|
1274
|
+
* this is the first snapshot, all documents will be in the list as added
|
|
1275
|
+
* changes.
|
|
1276
|
+
*/
|
|
1277
|
+
docChanges(): DocumentChange<T>[];
|
|
1278
|
+
/**
|
|
1279
|
+
* Enumerates all of the documents in the QuerySnapshot.
|
|
1280
|
+
*
|
|
1281
|
+
* @param callback A callback to be called with a `DocumentSnapshot` for
|
|
1282
|
+
* each document in the snapshot.
|
|
1283
|
+
* @param thisArg The `this` binding for the callback.
|
|
1284
|
+
*/
|
|
1285
|
+
forEach(callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?: any): void;
|
|
1286
|
+
/**
|
|
1287
|
+
* Returns true if the document data in this `QuerySnapshot` is equal to the
|
|
1288
|
+
* provided one.
|
|
1289
|
+
*
|
|
1290
|
+
* @param other The `QuerySnapshot` to compare against.
|
|
1291
|
+
* @return true if this `QuerySnapshot` is equal to the provided one.
|
|
1292
|
+
*/
|
|
1293
|
+
isEqual(other: QuerySnapshot<T>): boolean;
|
|
1488
1294
|
}
|
|
1489
|
-
|
|
1490
1295
|
/**
|
|
1491
1296
|
* The type of of a `DocumentChange` may be 'added', 'removed', or 'modified'.
|
|
1492
1297
|
*/
|
|
1493
1298
|
export type DocumentChangeType = 'added' | 'removed' | 'modified';
|
|
1494
|
-
|
|
1495
1299
|
/**
|
|
1496
1300
|
* A `DocumentChange` represents a change to the documents matching a query.
|
|
1497
1301
|
* It contains the document affected and the type of change that occurred.
|
|
1498
1302
|
*/
|
|
1499
1303
|
export interface DocumentChange<T = DocumentData> {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
* @param other The `DocumentChange` to compare against.
|
|
1526
|
-
* @return true if this `DocumentChange` is equal to the provided one.
|
|
1527
|
-
*/
|
|
1528
|
-
isEqual(other: DocumentChange<T>): boolean;
|
|
1304
|
+
/** The type of change ('added', 'modified', or 'removed'). */
|
|
1305
|
+
readonly type: DocumentChangeType;
|
|
1306
|
+
/** The document affected by this change. */
|
|
1307
|
+
readonly doc: QueryDocumentSnapshot<T>;
|
|
1308
|
+
/**
|
|
1309
|
+
* The index of the changed document in the result set immediately prior to
|
|
1310
|
+
* this DocumentChange (i.e. supposing that all prior DocumentChange objects
|
|
1311
|
+
* have been applied). Is -1 for 'added' events.
|
|
1312
|
+
*/
|
|
1313
|
+
readonly oldIndex: number;
|
|
1314
|
+
/**
|
|
1315
|
+
* The index of the changed document in the result set immediately after
|
|
1316
|
+
* this DocumentChange (i.e. supposing that all prior DocumentChange
|
|
1317
|
+
* objects and the current DocumentChange object have been applied).
|
|
1318
|
+
* Is -1 for 'removed' events.
|
|
1319
|
+
*/
|
|
1320
|
+
readonly newIndex: number;
|
|
1321
|
+
/**
|
|
1322
|
+
* Returns true if the data in this `DocumentChange` is equal to the
|
|
1323
|
+
* provided one.
|
|
1324
|
+
*
|
|
1325
|
+
* @param other The `DocumentChange` to compare against.
|
|
1326
|
+
* @return true if this `DocumentChange` is equal to the provided one.
|
|
1327
|
+
*/
|
|
1328
|
+
isEqual(other: DocumentChange<T>): boolean;
|
|
1529
1329
|
}
|
|
1530
|
-
|
|
1531
1330
|
/**
|
|
1532
1331
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
1533
1332
|
* document references, and querying for documents (using the methods
|
|
1534
1333
|
* inherited from `Query`).
|
|
1535
1334
|
*/
|
|
1536
|
-
export class CollectionReference<T = DocumentData> extends Query<T> {
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
* on the returned CollectionReference instance, the provided converter will
|
|
1608
|
-
* convert between Firestore data and your custom type U.
|
|
1609
|
-
*
|
|
1610
|
-
* @param converter Converts objects to and from Firestore. Passing in
|
|
1611
|
-
* `null` removes the current converter.
|
|
1612
|
-
* @return A CollectionReference<U> that uses the provided converter.
|
|
1613
|
-
*/
|
|
1614
|
-
withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
|
|
1615
|
-
withConverter(converter: null): CollectionReference<DocumentData>;
|
|
1335
|
+
export declare class CollectionReference<T = DocumentData> extends Query<T> {
|
|
1336
|
+
private constructor();
|
|
1337
|
+
/** The identifier of the collection. */
|
|
1338
|
+
readonly id: string;
|
|
1339
|
+
/**
|
|
1340
|
+
* A reference to the containing Document if this is a subcollection, else
|
|
1341
|
+
* null.
|
|
1342
|
+
*/
|
|
1343
|
+
readonly parent: DocumentReference<DocumentData> | null;
|
|
1344
|
+
/**
|
|
1345
|
+
* A string representing the path of the referenced collection (relative
|
|
1346
|
+
* to the root of the database).
|
|
1347
|
+
*/
|
|
1348
|
+
readonly path: string;
|
|
1349
|
+
/**
|
|
1350
|
+
* Retrieves the list of documents in this collection.
|
|
1351
|
+
*
|
|
1352
|
+
* The document references returned may include references to "missing
|
|
1353
|
+
* documents", i.e. document locations that have no document present but
|
|
1354
|
+
* which contain subcollections with documents. Attempting to read such a
|
|
1355
|
+
* document reference (e.g. via `.get()` or `.onSnapshot()`) will return a
|
|
1356
|
+
* `DocumentSnapshot` whose `.exists` property is false.
|
|
1357
|
+
*
|
|
1358
|
+
* @return {Promise<DocumentReference[]>} The list of documents in this
|
|
1359
|
+
* collection.
|
|
1360
|
+
*/
|
|
1361
|
+
listDocuments(): Promise<Array<DocumentReference<T>>>;
|
|
1362
|
+
/**
|
|
1363
|
+
* Get a `DocumentReference` for a randomly-named document within this
|
|
1364
|
+
* collection. An automatically-generated unique ID will be used as the
|
|
1365
|
+
* document ID.
|
|
1366
|
+
*
|
|
1367
|
+
* @return The `DocumentReference` instance.
|
|
1368
|
+
*/
|
|
1369
|
+
doc(): DocumentReference<T>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Get a `DocumentReference` for the document within the collection at the
|
|
1372
|
+
* specified path.
|
|
1373
|
+
*
|
|
1374
|
+
* @param documentPath A slash-separated path to a document.
|
|
1375
|
+
* @return The `DocumentReference` instance.
|
|
1376
|
+
*/
|
|
1377
|
+
doc(documentPath: string): DocumentReference<T>;
|
|
1378
|
+
/**
|
|
1379
|
+
* Add a new document to this collection with the specified data, assigning
|
|
1380
|
+
* it a document ID automatically.
|
|
1381
|
+
*
|
|
1382
|
+
* @param data An Object containing the data for the new document.
|
|
1383
|
+
* @return A Promise resolved with a `DocumentReference` pointing to the
|
|
1384
|
+
* newly created document after it has been written to the backend.
|
|
1385
|
+
*/
|
|
1386
|
+
add(data: T): Promise<DocumentReference<T>>;
|
|
1387
|
+
/**
|
|
1388
|
+
* Returns true if this `CollectionReference` is equal to the provided one.
|
|
1389
|
+
*
|
|
1390
|
+
* @param other The `CollectionReference` to compare against.
|
|
1391
|
+
* @return true if this `CollectionReference` is equal to the provided one.
|
|
1392
|
+
*/
|
|
1393
|
+
isEqual(other: CollectionReference<T>): boolean;
|
|
1394
|
+
/**
|
|
1395
|
+
* Applies a custom data converter to this CollectionReference, allowing you
|
|
1396
|
+
* to use your own custom model objects with Firestore. When you call add()
|
|
1397
|
+
* on the returned CollectionReference instance, the provided converter will
|
|
1398
|
+
* convert between Firestore data and your custom type U.
|
|
1399
|
+
*
|
|
1400
|
+
* @param converter Converts objects to and from Firestore. Passing in
|
|
1401
|
+
* `null` removes the current converter.
|
|
1402
|
+
* @return A CollectionReference<U> that uses the provided converter.
|
|
1403
|
+
*/
|
|
1404
|
+
withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
|
|
1405
|
+
withConverter(converter: null): CollectionReference<DocumentData>;
|
|
1616
1406
|
}
|
|
1617
|
-
|
|
1618
1407
|
/**
|
|
1619
1408
|
* A `CollectionGroup` refers to all documents that are contained in a
|
|
1620
1409
|
* collection or subcollection with a specific collection ID.
|
|
1621
1410
|
*/
|
|
1622
|
-
export class CollectionGroup<T = DocumentData> extends Query<T> {
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
withConverter<U>(converter: FirestoreDataConverter<U>): CollectionGroup<U>;
|
|
1683
|
-
withConverter(converter: null): CollectionGroup<DocumentData>;
|
|
1411
|
+
export declare class CollectionGroup<T = DocumentData> extends Query<T> {
|
|
1412
|
+
private constructor();
|
|
1413
|
+
/**
|
|
1414
|
+
* Partitions a query by returning partition cursors that can be used to run
|
|
1415
|
+
* the query in parallel. The returned cursors are split points that can be
|
|
1416
|
+
* used as starting and end points for individual query invocations.
|
|
1417
|
+
*
|
|
1418
|
+
* @param desiredPartitionCount The desired maximum number of partition
|
|
1419
|
+
* points. The number must be strictly positive. The actual number of
|
|
1420
|
+
* partitions returned may be fewer.
|
|
1421
|
+
* @return An AsyncIterable of `QueryPartition`s.
|
|
1422
|
+
*/
|
|
1423
|
+
getPartitions(desiredPartitionCount: number): AsyncIterable<QueryPartition<T>>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Applies a custom data converter to this `CollectionGroup`, allowing you
|
|
1426
|
+
* to use your own custom model objects with Firestore. When you call get()
|
|
1427
|
+
* on the returned `CollectionGroup`, the provided converter will convert
|
|
1428
|
+
* between Firestore data and your custom type U.
|
|
1429
|
+
*
|
|
1430
|
+
* Using the converter allows you to specify generic type arguments when
|
|
1431
|
+
* storing and retrieving objects from Firestore.
|
|
1432
|
+
*
|
|
1433
|
+
* @example
|
|
1434
|
+
* class Post {
|
|
1435
|
+
* constructor(readonly title: string, readonly author: string) {}
|
|
1436
|
+
*
|
|
1437
|
+
* toString(): string {
|
|
1438
|
+
* return this.title + ', by ' + this.author;
|
|
1439
|
+
* }
|
|
1440
|
+
* }
|
|
1441
|
+
*
|
|
1442
|
+
* const postConverter = {
|
|
1443
|
+
* toFirestore(post: Post): FirebaseFirestore.DocumentData {
|
|
1444
|
+
* return {title: post.title, author: post.author};
|
|
1445
|
+
* },
|
|
1446
|
+
* fromFirestore(
|
|
1447
|
+
* snapshot: FirebaseFirestore.QueryDocumentSnapshot
|
|
1448
|
+
* ): Post {
|
|
1449
|
+
* const data = snapshot.data();
|
|
1450
|
+
* return new Post(data.title, data.author);
|
|
1451
|
+
* }
|
|
1452
|
+
* };
|
|
1453
|
+
*
|
|
1454
|
+
* const querySnapshot = await Firestore()
|
|
1455
|
+
* .collectionGroup('posts')
|
|
1456
|
+
* .withConverter(postConverter)
|
|
1457
|
+
* .get();
|
|
1458
|
+
* for (const doc of querySnapshot.docs) {
|
|
1459
|
+
* const post = doc.data();
|
|
1460
|
+
* post.title; // string
|
|
1461
|
+
* post.toString(); // Should be defined
|
|
1462
|
+
* post.someNonExistentProperty; // TS error
|
|
1463
|
+
* }
|
|
1464
|
+
*
|
|
1465
|
+
* @param converter Converts objects to and from Firestore. Passing in
|
|
1466
|
+
* `null` removes the current converter.
|
|
1467
|
+
* @return A `CollectionGroup<U>` that uses the provided converter.
|
|
1468
|
+
*/
|
|
1469
|
+
withConverter<U>(converter: FirestoreDataConverter<U>): CollectionGroup<U>;
|
|
1470
|
+
withConverter(converter: null): CollectionGroup<DocumentData>;
|
|
1684
1471
|
}
|
|
1685
|
-
|
|
1686
1472
|
/**
|
|
1687
1473
|
* A split point that can be used in a query as a starting and/or end point for
|
|
1688
1474
|
* the query results. The cursors returned by {@link #startAt} and {@link
|
|
1689
1475
|
* #endBefore} can only be used in a query that matches the constraint of query
|
|
1690
1476
|
* that produced this partition.
|
|
1691
1477
|
*/
|
|
1692
|
-
export class QueryPartition<T = DocumentData> {
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
* Query#endBefore} cursor.
|
|
1722
|
-
*/
|
|
1723
|
-
toQuery(): Query<T>;
|
|
1478
|
+
export declare class QueryPartition<T = DocumentData> {
|
|
1479
|
+
private constructor();
|
|
1480
|
+
/**
|
|
1481
|
+
* The cursor that defines the first result for this partition or
|
|
1482
|
+
* `undefined` if this is the first partition. The cursor value must be
|
|
1483
|
+
* destructured when passed to `startAt()` (for example with
|
|
1484
|
+
* `query.startAt(...queryPartition.startAt)`).
|
|
1485
|
+
*
|
|
1486
|
+
* @return Cursor values that can be used with {@link Query#startAt} or
|
|
1487
|
+
* `undefined` if this is the first partition.
|
|
1488
|
+
*/
|
|
1489
|
+
get startAt(): unknown[] | undefined;
|
|
1490
|
+
/**
|
|
1491
|
+
* The cursor that defines the first result after this partition or
|
|
1492
|
+
* `undefined` if this is the last partition. The cursor value must be
|
|
1493
|
+
* destructured when passed to `endBefore()` (for example with
|
|
1494
|
+
* `query.endBefore(...queryPartition.endBefore)`).
|
|
1495
|
+
*
|
|
1496
|
+
* @return Cursor values that can be used with {@link Query#endBefore} or
|
|
1497
|
+
* `undefined` if this is the last partition.
|
|
1498
|
+
*/
|
|
1499
|
+
get endBefore(): unknown[] | undefined;
|
|
1500
|
+
/**
|
|
1501
|
+
* Returns a query that only returns the documents for this partition.
|
|
1502
|
+
*
|
|
1503
|
+
* @return A query partitioned by a {@link Query#startAt} and {@link
|
|
1504
|
+
* Query#endBefore} cursor.
|
|
1505
|
+
*/
|
|
1506
|
+
toQuery(): Query<T>;
|
|
1724
1507
|
}
|
|
1725
|
-
|
|
1726
1508
|
/**
|
|
1727
1509
|
* Sentinel values that can be used when writing document fields with set(),
|
|
1728
1510
|
* create() or update().
|
|
1729
1511
|
*/
|
|
1730
|
-
export class FieldValue {
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
* Returns true if this `FieldValue` is equal to the provided one.
|
|
1798
|
-
*
|
|
1799
|
-
* @param other The `FieldValue` to compare against.
|
|
1800
|
-
* @return true if this `FieldValue` is equal to the provided one.
|
|
1801
|
-
*/
|
|
1802
|
-
isEqual(other: FieldValue): boolean;
|
|
1512
|
+
export declare class FieldValue {
|
|
1513
|
+
private constructor();
|
|
1514
|
+
/**
|
|
1515
|
+
* Returns a sentinel used with set(), create() or update() to include a
|
|
1516
|
+
* server-generated timestamp in the written data.
|
|
1517
|
+
*
|
|
1518
|
+
* @return The FieldValue sentinel for use in a call to set(), create() or
|
|
1519
|
+
* update().
|
|
1520
|
+
*/
|
|
1521
|
+
static serverTimestamp(): FieldValue;
|
|
1522
|
+
/**
|
|
1523
|
+
* Returns a sentinel for use with update() or set() with {merge:true} to
|
|
1524
|
+
* mark a field for deletion.
|
|
1525
|
+
*
|
|
1526
|
+
* @return The FieldValue sentinel for use in a call to set() or update().
|
|
1527
|
+
*/
|
|
1528
|
+
static delete(): FieldValue;
|
|
1529
|
+
/**
|
|
1530
|
+
* Returns a special value that can be used with set(), create() or update()
|
|
1531
|
+
* that tells the server to increment the field's current value by the given
|
|
1532
|
+
* value.
|
|
1533
|
+
*
|
|
1534
|
+
* If either current field value or the operand uses floating point
|
|
1535
|
+
* precision, both values will be interpreted as floating point numbers and
|
|
1536
|
+
* all arithmetic will follow IEEE 754 semantics. Otherwise, integer
|
|
1537
|
+
* precision is kept and the result is capped between -2^63 and 2^63-1.
|
|
1538
|
+
*
|
|
1539
|
+
* If the current field value is not of type 'number', or if the field does
|
|
1540
|
+
* not yet exist, the transformation will set the field to the given value.
|
|
1541
|
+
*
|
|
1542
|
+
* @param n The value to increment by.
|
|
1543
|
+
* @return The FieldValue sentinel for use in a call to set(), create() or
|
|
1544
|
+
* update().
|
|
1545
|
+
*/
|
|
1546
|
+
static increment(n: number): FieldValue;
|
|
1547
|
+
/**
|
|
1548
|
+
* Returns a special value that can be used with set(), create() or update()
|
|
1549
|
+
* that tells the server to union the given elements with any array value
|
|
1550
|
+
* that already exists on the server. Each specified element that doesn't
|
|
1551
|
+
* already exist in the array will be added to the end. If the field being
|
|
1552
|
+
* modified is not already an array it will be overwritten with an array
|
|
1553
|
+
* containing exactly the specified elements.
|
|
1554
|
+
*
|
|
1555
|
+
* @param elements The elements to union into the array.
|
|
1556
|
+
* @return The FieldValue sentinel for use in a call to set(), create() or
|
|
1557
|
+
* update().
|
|
1558
|
+
*/
|
|
1559
|
+
static arrayUnion(...elements: any[]): FieldValue;
|
|
1560
|
+
/**
|
|
1561
|
+
* Returns a special value that can be used with set(), create() or update()
|
|
1562
|
+
* that tells the server to remove the given elements from any array value
|
|
1563
|
+
* that already exists on the server. All instances of each element
|
|
1564
|
+
* specified will be removed from the array. If the field being modified is
|
|
1565
|
+
* not already an array it will be overwritten with an empty array.
|
|
1566
|
+
*
|
|
1567
|
+
* @param elements The elements to remove from the array.
|
|
1568
|
+
* @return The FieldValue sentinel for use in a call to set(), create() or
|
|
1569
|
+
* update().
|
|
1570
|
+
*/
|
|
1571
|
+
static arrayRemove(...elements: any[]): FieldValue;
|
|
1572
|
+
/**
|
|
1573
|
+
* Returns true if this `FieldValue` is equal to the provided one.
|
|
1574
|
+
*
|
|
1575
|
+
* @param other The `FieldValue` to compare against.
|
|
1576
|
+
* @return true if this `FieldValue` is equal to the provided one.
|
|
1577
|
+
*/
|
|
1578
|
+
isEqual(other: FieldValue): boolean;
|
|
1803
1579
|
}
|
|
1804
|
-
|
|
1805
1580
|
/**
|
|
1806
1581
|
* A FieldPath refers to a field in a document. The path may consist of a
|
|
1807
1582
|
* single field name (referring to a top-level field in the document), or a
|
|
1808
1583
|
* list of field names (referring to a nested field in the document).
|
|
1809
1584
|
*/
|
|
1810
|
-
export class FieldPath {
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
*/
|
|
1831
|
-
isEqual(other: FieldPath): boolean;
|
|
1585
|
+
export declare class FieldPath {
|
|
1586
|
+
/**
|
|
1587
|
+
* Creates a FieldPath from the provided field names. If more than one field
|
|
1588
|
+
* name is provided, the path will point to a nested field in a document.
|
|
1589
|
+
*
|
|
1590
|
+
* @param fieldNames A list of field names.
|
|
1591
|
+
*/
|
|
1592
|
+
constructor(...fieldNames: string[]);
|
|
1593
|
+
/**
|
|
1594
|
+
* Returns a special sentinel FieldPath to refer to the ID of a document.
|
|
1595
|
+
* It can be used in queries to sort or filter by the document ID.
|
|
1596
|
+
*/
|
|
1597
|
+
static documentId(): FieldPath;
|
|
1598
|
+
/**
|
|
1599
|
+
* Returns true if this `FieldPath` is equal to the provided one.
|
|
1600
|
+
*
|
|
1601
|
+
* @param other The `FieldPath` to compare against.
|
|
1602
|
+
* @return true if this `FieldPath` is equal to the provided one.
|
|
1603
|
+
*/
|
|
1604
|
+
isEqual(other: FieldPath): boolean;
|
|
1832
1605
|
}
|
|
1833
|
-
|
|
1834
1606
|
/**
|
|
1835
1607
|
* A Timestamp represents a point in time independent of any time zone or
|
|
1836
1608
|
* calendar, represented as seconds and fractions of seconds at nanosecond
|
|
@@ -1842,157 +1614,134 @@ export class FieldPath {
|
|
|
1842
1614
|
*
|
|
1843
1615
|
* @see https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto
|
|
1844
1616
|
*/
|
|
1845
|
-
export class Timestamp {
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
isEqual(other: Timestamp): boolean;
|
|
1917
|
-
|
|
1918
|
-
/**
|
|
1919
|
-
* Converts this object to a primitive `string`, which allows `Timestamp` objects to be compared
|
|
1920
|
-
* using the `>`, `<=`, `>=` and `>` operators.
|
|
1921
|
-
*
|
|
1922
|
-
* @return a string encoding of this object.
|
|
1923
|
-
*/
|
|
1924
|
-
valueOf(): string;
|
|
1617
|
+
export declare class Timestamp {
|
|
1618
|
+
/**
|
|
1619
|
+
* Creates a new timestamp with the current date, with millisecond precision.
|
|
1620
|
+
*
|
|
1621
|
+
* @return A new `Timestamp` representing the current date.
|
|
1622
|
+
*/
|
|
1623
|
+
static now(): Timestamp;
|
|
1624
|
+
/**
|
|
1625
|
+
* Creates a new timestamp from the given date.
|
|
1626
|
+
*
|
|
1627
|
+
* @param date The date to initialize the `Timestamp` from.
|
|
1628
|
+
* @return A new `Timestamp` representing the same point in time as the
|
|
1629
|
+
* given date.
|
|
1630
|
+
*/
|
|
1631
|
+
static fromDate(date: Date): Timestamp;
|
|
1632
|
+
/**
|
|
1633
|
+
* Creates a new timestamp from the given number of milliseconds.
|
|
1634
|
+
*
|
|
1635
|
+
* @param milliseconds Number of milliseconds since Unix epoch
|
|
1636
|
+
* 1970-01-01T00:00:00Z.
|
|
1637
|
+
* @return A new `Timestamp` representing the same point in time as the
|
|
1638
|
+
* given number of milliseconds.
|
|
1639
|
+
*/
|
|
1640
|
+
static fromMillis(milliseconds: number): Timestamp;
|
|
1641
|
+
/**
|
|
1642
|
+
* Creates a new timestamp.
|
|
1643
|
+
*
|
|
1644
|
+
* @param seconds The number of seconds of UTC time since Unix epoch
|
|
1645
|
+
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
1646
|
+
* 9999-12-31T23:59:59Z inclusive.
|
|
1647
|
+
* @param nanoseconds The non-negative fractions of a second at nanosecond
|
|
1648
|
+
* resolution. Negative second values with fractions must still have
|
|
1649
|
+
* non-negative nanoseconds values that count forward in time. Must be from
|
|
1650
|
+
* 0 to 999,999,999 inclusive.
|
|
1651
|
+
*/
|
|
1652
|
+
constructor(seconds: number, nanoseconds: number);
|
|
1653
|
+
/**
|
|
1654
|
+
* The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
|
|
1655
|
+
*/
|
|
1656
|
+
readonly seconds: number;
|
|
1657
|
+
/** The non-negative fractions of a second at nanosecond resolution. */
|
|
1658
|
+
readonly nanoseconds: number;
|
|
1659
|
+
/**
|
|
1660
|
+
* Returns a new `Date` corresponding to this timestamp. This may lose
|
|
1661
|
+
* precision.
|
|
1662
|
+
*
|
|
1663
|
+
* @return JavaScript `Date` object representing the same point in time as
|
|
1664
|
+
* this `Timestamp`, with millisecond precision.
|
|
1665
|
+
*/
|
|
1666
|
+
toDate(): Date;
|
|
1667
|
+
/**
|
|
1668
|
+
* Returns the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
|
|
1669
|
+
*
|
|
1670
|
+
* @return The point in time corresponding to this timestamp, represented as
|
|
1671
|
+
* the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
|
|
1672
|
+
*/
|
|
1673
|
+
toMillis(): number;
|
|
1674
|
+
/**
|
|
1675
|
+
* Returns true if this `Timestamp` is equal to the provided one.
|
|
1676
|
+
*
|
|
1677
|
+
* @param other The `Timestamp` to compare against.
|
|
1678
|
+
* @return 'true' if this `Timestamp` is equal to the provided one.
|
|
1679
|
+
*/
|
|
1680
|
+
isEqual(other: Timestamp): boolean;
|
|
1681
|
+
/**
|
|
1682
|
+
* Converts this object to a primitive `string`, which allows `Timestamp` objects to be compared
|
|
1683
|
+
* using the `>`, `<=`, `>=` and `>` operators.
|
|
1684
|
+
*
|
|
1685
|
+
* @return a string encoding of this object.
|
|
1686
|
+
*/
|
|
1687
|
+
valueOf(): string;
|
|
1925
1688
|
}
|
|
1926
|
-
|
|
1927
1689
|
/**
|
|
1928
1690
|
* Builds a Firestore data bundle with results from the given document and query snapshots.
|
|
1929
1691
|
*/
|
|
1930
|
-
export class BundleBuilder {
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
* Builds the bundle and returns the result as a `Buffer` instance.
|
|
1955
|
-
*/
|
|
1956
|
-
build(): Buffer;
|
|
1692
|
+
export declare class BundleBuilder {
|
|
1693
|
+
/** The ID of this bundle. */
|
|
1694
|
+
readonly bundleId: string;
|
|
1695
|
+
/**
|
|
1696
|
+
* Adds a Firestore `DocumentSnapshot` to the bundle. Both the documents data and the document
|
|
1697
|
+
* read time will be included in the bundle.
|
|
1698
|
+
*
|
|
1699
|
+
* @param documentSnapshot A `DocumentSnapshot` to add.
|
|
1700
|
+
* @returns This instance.
|
|
1701
|
+
*/
|
|
1702
|
+
add<T>(documentSnapshot: DocumentSnapshot<T>): BundleBuilder;
|
|
1703
|
+
/**
|
|
1704
|
+
* Adds a Firestore `QuerySnapshot` to the bundle. Both the documents in the query results and
|
|
1705
|
+
* the query read time will be included in the bundle.
|
|
1706
|
+
*
|
|
1707
|
+
* @param queryName The name of the query to add.
|
|
1708
|
+
* @param querySnapshot A `QuerySnapshot` to add to the bundle.
|
|
1709
|
+
* @returns This instance.
|
|
1710
|
+
*/
|
|
1711
|
+
add<T>(queryName: string, querySnapshot: QuerySnapshot<T>): BundleBuilder;
|
|
1712
|
+
/**
|
|
1713
|
+
* Builds the bundle and returns the result as a `Buffer` instance.
|
|
1714
|
+
*/
|
|
1715
|
+
build(): Buffer;
|
|
1957
1716
|
}
|
|
1958
|
-
|
|
1959
1717
|
/**
|
|
1960
1718
|
* The v1beta1 Veneer client. This client provides access to to the underlying
|
|
1961
1719
|
* Firestore v1beta1 RPCs.
|
|
1962
1720
|
* @deprecated Use v1 instead.
|
|
1963
1721
|
*/
|
|
1964
|
-
// export const v1beta1: {
|
|
1965
|
-
// FirestoreClient: typeof import('./v1beta1/firestore_client').FirestoreClient;
|
|
1966
|
-
// };
|
|
1967
|
-
|
|
1968
1722
|
/**
|
|
1969
1723
|
* The v1 Veneer clients. These clients provide access to the Firestore Admin
|
|
1970
1724
|
* API and the underlying Firestore v1 RPCs.
|
|
1971
1725
|
*/
|
|
1972
|
-
// export const v1: {
|
|
1973
|
-
// FirestoreClient: typeof import('./v1/firestore_client').FirestoreClient;
|
|
1974
|
-
// FirestoreAdminClient: typeof import('./v1/firestore_admin_client').FirestoreAdminClient;
|
|
1975
|
-
// };
|
|
1976
|
-
|
|
1977
1726
|
/**
|
|
1978
1727
|
* Status codes returned by Firestore's gRPC calls.
|
|
1979
1728
|
*/
|
|
1980
|
-
export enum GrpcStatus {
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1729
|
+
export declare enum GrpcStatus {
|
|
1730
|
+
OK = 0,
|
|
1731
|
+
CANCELLED = 1,
|
|
1732
|
+
UNKNOWN = 2,
|
|
1733
|
+
INVALID_ARGUMENT = 3,
|
|
1734
|
+
DEADLINE_EXCEEDED = 4,
|
|
1735
|
+
NOT_FOUND = 5,
|
|
1736
|
+
ALREADY_EXISTS = 6,
|
|
1737
|
+
PERMISSION_DENIED = 7,
|
|
1738
|
+
RESOURCE_EXHAUSTED = 8,
|
|
1739
|
+
FAILED_PRECONDITION = 9,
|
|
1740
|
+
ABORTED = 10,
|
|
1741
|
+
OUT_OF_RANGE = 11,
|
|
1742
|
+
UNIMPLEMENTED = 12,
|
|
1743
|
+
INTERNAL = 13,
|
|
1744
|
+
UNAVAILABLE = 14,
|
|
1745
|
+
DATA_LOSS = 15,
|
|
1746
|
+
UNAUTHENTICATED = 16
|
|
1998
1747
|
}
|