1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import { FirebaseApp } from '@firebase/app';
|
7 | import { LogLevelString as LogLevel } from '@firebase/logger';
|
8 | import { EmulatorMockTokenOptions } from '@firebase/util';
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export declare function addDoc<T>(reference: CollectionReference<T>, data: WithFieldValue<T>): Promise<DocumentReference<T>>;
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
|
26 | [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
|
27 | };
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | export declare function arrayRemove(...elements: unknown[]): FieldValue;
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | export declare function arrayUnion(...elements: unknown[]): FieldValue;
|
53 |
|
54 |
|
55 |
|
56 | export declare class Bytes {
|
57 | private constructor();
|
58 | /**
|
59 | * Creates a new `Bytes` object from the given Base64 string, converting it to
|
60 | * bytes.
|
61 | *
|
62 | * @param base64 - The Base64 string used to create the `Bytes` object.
|
63 | */
|
64 | static fromBase64String(base64: string): Bytes;
|
65 | /**
|
66 | * Creates a new `Bytes` object from the given Uint8Array.
|
67 | *
|
68 | * @param array - The Uint8Array used to create the `Bytes` object.
|
69 | */
|
70 | static fromUint8Array(array: Uint8Array): Bytes;
|
71 | /**
|
72 | * Returns the underlying bytes as a Base64-encoded string.
|
73 | *
|
74 | * @returns The Base64-encoded string created from the `Bytes` object.
|
75 | */
|
76 | toBase64(): string;
|
77 | /**
|
78 | * Returns the underlying bytes in a new `Uint8Array`.
|
79 | *
|
80 | * @returns The Uint8Array created from the `Bytes` object.
|
81 | */
|
82 | toUint8Array(): Uint8Array;
|
83 | /**
|
84 | * Returns a string representation of the `Bytes` object.
|
85 | *
|
86 | * @returns A string representation of the `Bytes` object.
|
87 | */
|
88 | toString(): string;
|
89 | /**
|
90 | * Returns true if this `Bytes` object is equal to the provided one.
|
91 | *
|
92 | * @param other - The `Bytes` object to compare against.
|
93 | * @returns true if this `Bytes` object is equal to the provided one.
|
94 | */
|
95 | isEqual(other: Bytes): boolean;
|
96 | }
|
97 | /* Excluded from this release type: _ByteString */
|
98 | /**
|
99 | * Constant used to indicate the LRU garbage collection should be disabled.
|
100 | * Set this value as the `cacheSizeBytes` on the settings passed to the
|
101 | * {@link Firestore} instance.
|
102 | */
|
103 | export declare const CACHE_SIZE_UNLIMITED = -1;
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 | export declare type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never;
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | export declare function clearIndexedDbPersistence(firestore: Firestore): Promise<void>;
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | export declare function collection(reference: CollectionReference<unknown>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 | export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | export declare function collectionGroup(firestore: Firestore, collectionId: string): Query<DocumentData>;
|
189 |
|
190 |
|
191 |
|
192 |
|
193 | export declare class CollectionReference<T = DocumentData> extends Query<T> {
|
194 |
|
195 | readonly type = "collection";
|
196 | private constructor();
|
197 | /** The collection's identifier. */
|
198 | get id(): string;
|
199 | /**
|
200 | * A string representing the path of the referenced collection (relative
|
201 | * to the root of the database).
|
202 | */
|
203 | get path(): string;
|
204 | /**
|
205 | * A reference to the containing `DocumentReference` if this is a
|
206 | * subcollection. If this isn't a subcollection, the reference is null.
|
207 | */
|
208 | get parent(): DocumentReference<DocumentData> | null;
|
209 | /**
|
210 | * Applies a custom data converter to this `CollectionReference`, allowing you
|
211 | * to use your own custom model objects with Firestore. When you call {@link
|
212 | * addDoc} with the returned `CollectionReference` instance, the provided
|
213 | * converter will convert between Firestore data and your custom type `U`.
|
214 | *
|
215 | * @param converter - Converts objects to and from Firestore.
|
216 | * @returns A `CollectionReference<U>` that uses the provided converter.
|
217 | */
|
218 | withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
|
219 | |
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 | withConverter(converter: null): CollectionReference<DocumentData>;
|
227 | }
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
|
242 | mockUserToken?: EmulatorMockTokenOptions | string;
|
243 | }): void;
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 | export declare function deleteDoc(reference: DocumentReference<unknown>): Promise<void>;
|
252 |
|
253 |
|
254 |
|
255 |
|
256 | export declare function deleteField(): FieldValue;
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 | export declare function disableNetwork(firestore: Firestore): Promise<void>;
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 | export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 | export declare function doc<T>(reference: CollectionReference<T>, path?: string, ...pathSegments: string[]): DocumentReference<T>;
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 | export declare function doc(reference: DocumentReference<unknown>, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
|
308 |
|
309 |
|
310 |
|
311 |
|
312 | export declare interface DocumentChange<T = DocumentData> {
|
313 |
|
314 | readonly type: DocumentChangeType;
|
315 |
|
316 | readonly doc: QueryDocumentSnapshot<T>;
|
317 | |
318 |
|
319 |
|
320 |
|
321 |
|
322 | readonly oldIndex: number;
|
323 | |
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 | readonly newIndex: number;
|
330 | }
|
331 |
|
332 |
|
333 |
|
334 | export declare type DocumentChangeType = 'added' | 'removed' | 'modified';
|
335 |
|
336 |
|
337 |
|
338 |
|
339 | export declare interface DocumentData {
|
340 |
|
341 | [field: string]: any;
|
342 | }
|
343 |
|
344 |
|
345 |
|
346 |
|
347 | export declare function documentId(): FieldPath;
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 | export declare class DocumentReference<T = DocumentData> {
|
354 | |
355 |
|
356 |
|
357 | readonly converter: FirestoreDataConverter<T> | null;
|
358 |
|
359 | readonly type = "document";
|
360 | |
361 |
|
362 |
|
363 |
|
364 | readonly firestore: Firestore;
|
365 | private constructor();
|
366 | /**
|
367 | * The document's identifier within its collection.
|
368 | */
|
369 | get id(): string;
|
370 | /**
|
371 | * A string representing the path of the referenced document (relative
|
372 | * to the root of the database).
|
373 | */
|
374 | get path(): string;
|
375 | /**
|
376 | * The collection this `DocumentReference` belongs to.
|
377 | */
|
378 | get parent(): CollectionReference<T>;
|
379 | /**
|
380 | * Applies a custom data converter to this `DocumentReference`, allowing you
|
381 | * to use your own custom model objects with Firestore. When you call {@link
|
382 | * @firebase/firestore/lite#(setDoc:1)}, {@link @firebase/firestore/lite#getDoc}, etc. with the returned `DocumentReference`
|
383 | * instance, the provided converter will convert between Firestore data and
|
384 | * your custom type `U`.
|
385 | *
|
386 | * @param converter - Converts objects to and from Firestore.
|
387 | * @returns A `DocumentReference<U>` that uses the provided converter.
|
388 | */
|
389 | withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
|
390 | |
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 | withConverter(converter: null): DocumentReference<DocumentData>;
|
397 | }
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 | export declare class DocumentSnapshot<T = DocumentData> {
|
408 | |
409 |
|
410 |
|
411 |
|
412 | readonly metadata: SnapshotMetadata;
|
413 | protected constructor();
|
414 | /**
|
415 | * Property of the `DocumentSnapshot` that signals whether or not the data
|
416 | * exists. True if the document exists.
|
417 | */
|
418 | exists(): this is QueryDocumentSnapshot<T>;
|
419 | /**
|
420 | * Retrieves all fields in the document as an `Object`. Returns `undefined` if
|
421 | * the document doesn't exist.
|
422 | *
|
423 | * By default, `FieldValue.serverTimestamp()` values that have not yet been
|
424 | * set to their final value will be returned as `null`. You can override
|
425 | * this by passing an options object.
|
426 | *
|
427 | * @param options - An options object to configure how data is retrieved from
|
428 | * the snapshot (for example the desired behavior for server timestamps that
|
429 | * have not yet been set to their final value).
|
430 | * @returns An `Object` containing all fields in the document or `undefined` if
|
431 | * the document doesn't exist.
|
432 | */
|
433 | data(options?: SnapshotOptions): T | undefined;
|
434 | /**
|
435 | * Retrieves the field specified by `fieldPath`. Returns `undefined` if the
|
436 | * document or field doesn't exist.
|
437 | *
|
438 | * By default, a `FieldValue.serverTimestamp()` that has not yet been set to
|
439 | * its final value will be returned as `null`. You can override this by
|
440 | * passing an options object.
|
441 | *
|
442 | * @param fieldPath - The path (for example 'foo' or 'foo.bar') to a specific
|
443 | * field.
|
444 | * @param options - An options object to configure how the field is retrieved
|
445 | * from the snapshot (for example the desired behavior for server timestamps
|
446 | * that have not yet been set to their final value).
|
447 | * @returns The data at the specified field location or undefined if no such
|
448 | * field exists in the document.
|
449 | */
|
450 | get(fieldPath: string | FieldPath, options?: SnapshotOptions): any;
|
451 | /**
|
452 | * Property of the `DocumentSnapshot` that provides the document's ID.
|
453 | */
|
454 | get id(): string;
|
455 | /**
|
456 | * The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
457 | */
|
458 | get ref(): DocumentReference<T>;
|
459 | }
|
460 | /* Excluded from this release type: _EmptyCredentialsProvider */
|
461 | export { EmulatorMockTokenOptions };
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 | export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise<void>;
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 | export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void>;
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 | export declare function enableNetwork(firestore: Firestore): Promise<void>;
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 | export declare function endAt(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 | export declare function endAt(...fieldValues: unknown[]): QueryConstraint;
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 | export declare function endBefore(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 | export declare function endBefore(...fieldValues: unknown[]): QueryConstraint;
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 | export declare class FieldPath {
|
565 | |
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 | constructor(...fieldNames: string[]);
|
572 | /**
|
573 | * Returns true if this `FieldPath` is equal to the provided one.
|
574 | *
|
575 | * @param other - The `FieldPath` to compare against.
|
576 | * @returns true if this `FieldPath` is equal to the provided one.
|
577 | */
|
578 | isEqual(other: FieldPath): boolean;
|
579 | }
|
580 | /**
|
581 | * Sentinel values that can be used when writing document fields with `set()`
|
582 | * or `update()`.
|
583 | */
|
584 | export declare abstract class FieldValue {
|
585 | private constructor();
|
586 | /** Compares `FieldValue`s for equality. */
|
587 | abstract isEqual(other: FieldValue): boolean;
|
588 | }
|
589 | /* Excluded from this release type: _FirebaseService */
|
590 | /**
|
591 | * The Cloud Firestore service interface.
|
592 | *
|
593 | * Do not call this constructor directly. Instead, use {@link getFirestore}.
|
594 | */
|
595 | export declare class Firestore {
|
596 | |
597 |
|
598 |
|
599 | type: 'firestore-lite' | 'firestore';
|
600 | private constructor();
|
601 | /**
|
602 | * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
603 | * instance.
|
604 | */
|
605 | get app(): FirebaseApp;
|
606 | |
607 |
|
608 |
|
609 | toJSON(): object;
|
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 | export declare interface FirestoreDataConverter<T> {
|
654 | |
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 | toFirestore(modelObject: WithFieldValue<T>): DocumentData;
|
664 | |
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 | toFirestore(modelObject: PartialWithFieldValue<T>, options: SetOptions): DocumentData;
|
676 | |
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | fromFirestore(snapshot: QueryDocumentSnapshot<DocumentData>, options?: SnapshotOptions): T;
|
684 | }
|
685 |
|
686 | export declare class FirestoreError extends Error {
|
687 | |
688 |
|
689 |
|
690 | readonly code: FirestoreErrorCode;
|
691 | |
692 |
|
693 |
|
694 | readonly message: string;
|
695 |
|
696 | readonly name: string;
|
697 |
|
698 | readonly stack?: string;
|
699 | private constructor();
|
700 | }
|
701 | /**
|
702 | * @license
|
703 | * Copyright 2017 Google LLC
|
704 | *
|
705 | * Licensed under the Apache License, Version 2.0 (the "License");
|
706 | * you may not use this file except in compliance with the License.
|
707 | * You may obtain a copy of the License at
|
708 | *
|
709 | * http://www.apache.org/licenses/LICENSE-2.0
|
710 | *
|
711 | * Unless required by applicable law or agreed to in writing, software
|
712 | * distributed under the License is distributed on an "AS IS" BASIS,
|
713 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
714 | * See the License for the specific language governing permissions and
|
715 | * limitations under the License.
|
716 | */
|
717 | /**
|
718 | * The set of Firestore status codes. The codes are the same at the ones
|
719 | * exposed by gRPC here:
|
720 | * https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
721 | *
|
722 | * Possible values:
|
723 | * - 'cancelled': The operation was cancelled (typically by the caller).
|
724 | * - 'unknown': Unknown error or an error from a different error domain.
|
725 | * - 'invalid-argument': Client specified an invalid argument. Note that this
|
726 | * differs from 'failed-precondition'. 'invalid-argument' indicates
|
727 | * arguments that are problematic regardless of the state of the system
|
728 | * (e.g. an invalid field name).
|
729 | * - 'deadline-exceeded': Deadline expired before operation could complete.
|
730 | * For operations that change the state of the system, this error may be
|
731 | * returned even if the operation has completed successfully. For example,
|
732 | * a successful response from a server could have been delayed long enough
|
733 | * for the deadline to expire.
|
734 | * - 'not-found': Some requested document was not found.
|
735 | * - 'already-exists': Some document that we attempted to create already
|
736 | * exists.
|
737 | * - 'permission-denied': The caller does not have permission to execute the
|
738 | * specified operation.
|
739 | * - 'resource-exhausted': Some resource has been exhausted, perhaps a
|
740 | * per-user quota, or perhaps the entire file system is out of space.
|
741 | * - 'failed-precondition': Operation was rejected because the system is not
|
742 | * in a state required for the operation's execution.
|
743 | * - 'aborted': The operation was aborted, typically due to a concurrency
|
744 | * issue like transaction aborts, etc.
|
745 | * - 'out-of-range': Operation was attempted past the valid range.
|
746 | * - 'unimplemented': Operation is not implemented or not supported/enabled.
|
747 | * - 'internal': Internal errors. Means some invariants expected by
|
748 | * underlying system has been broken. If you see one of these errors,
|
749 | * something is very broken.
|
750 | * - 'unavailable': The service is currently unavailable. This is most likely
|
751 | * a transient condition and may be corrected by retrying with a backoff.
|
752 | * - 'data-loss': Unrecoverable data loss or corruption.
|
753 | * - 'unauthenticated': The request does not have valid authentication
|
754 | * credentials for the operation.
|
755 | */
|
756 | export declare type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';
|
757 | /**
|
758 | * Specifies custom configurations for your Cloud Firestore instance.
|
759 | * You must set these before invoking any other methods.
|
760 | */
|
761 | export declare interface FirestoreSettings {
|
762 | |
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 |
|
770 |
|
771 |
|
772 | cacheSizeBytes?: number;
|
773 | |
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 | experimentalForceLongPolling?: boolean;
|
788 | |
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 |
|
796 | experimentalAutoDetectLongPolling?: boolean;
|
797 | |
798 |
|
799 |
|
800 | host?: string;
|
801 | |
802 |
|
803 |
|
804 | ssl?: boolean;
|
805 | |
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 | ignoreUndefinedProperties?: boolean;
|
812 | }
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 |
|
834 |
|
835 |
|
836 | export declare class GeoPoint {
|
837 | |
838 |
|
839 |
|
840 |
|
841 |
|
842 |
|
843 | constructor(latitude: number, longitude: number);
|
844 | /**
|
845 | * The latitude of this `GeoPoint` instance.
|
846 | */
|
847 | get latitude(): number;
|
848 | /**
|
849 | * The longitude of this `GeoPoint` instance.
|
850 | */
|
851 | get longitude(): number;
|
852 | /**
|
853 | * Returns true if this `GeoPoint` is equal to the provided one.
|
854 | *
|
855 | * @param other - The `GeoPoint` to compare against.
|
856 | * @returns true if this `GeoPoint` is equal to the provided one.
|
857 | */
|
858 | isEqual(other: GeoPoint): boolean;
|
859 | /** Returns a JSON-serializable representation of this GeoPoint. */
|
860 | toJSON(): {
|
861 | latitude: number;
|
862 | longitude: number;
|
863 | };
|
864 | }
|
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 | export declare function getDoc<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 | export declare function getDocFromCache<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 | export declare function getDocFromServer<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 |
|
904 | export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 | export declare function getDocsFromCache<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 | export declare function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 | export declare function getFirestore(app?: FirebaseApp): Firestore;
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 |
|
948 | export declare function increment(n: number): FieldValue;
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 | export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings): Firestore;
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 | export declare function limit(limit: number): QueryConstraint;
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 |
|
977 |
|
978 | export declare function limitToLast(limit: number): QueryConstraint;
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 | export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 | export declare class LoadBundleTask implements PromiseLike<LoadBundleTaskProgress> {
|
998 | |
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 | onProgress(next?: (progress: LoadBundleTaskProgress) => unknown, error?: (err: Error) => unknown, complete?: () => void): void;
|
1007 | |
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 | catch<R>(onRejected: (a: Error) => R | PromiseLike<R>): Promise<R | LoadBundleTaskProgress>;
|
1013 | /**
|
1014 | * Implements the `Promise<LoadBundleTaskProgress>.then` interface.
|
1015 | *
|
1016 | * @param onFulfilled - Called on the completion of the loading task with a final `LoadBundleTaskProgress` update.
|
1017 | * The update will always have its `taskState` set to `"Success"`.
|
1018 | * @param onRejected - Called when an error occurs during bundle loading.
|
1019 | */
|
1020 | then<T, R>(onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>, onRejected?: (a: Error) => R | PromiseLike<R>): Promise<T | R>;
|
1021 | }
|
1022 | /**
|
1023 | * Represents a progress update or a final state from loading bundles.
|
1024 | */
|
1025 | export declare interface LoadBundleTaskProgress {
|
1026 | /** How many documents have been loaded. */
|
1027 | documentsLoaded: number;
|
1028 | /** How many documents are in the bundle being loaded. */
|
1029 | totalDocuments: number;
|
1030 | /** How many bytes have been loaded. */
|
1031 | bytesLoaded: number;
|
1032 | /** How many bytes are in the bundle being loaded. */
|
1033 | totalBytes: number;
|
1034 | /** Current task state. */
|
1035 | taskState: TaskState;
|
1036 | }
|
1037 | export { LogLevel };
|
1038 | /**
|
1039 | * Reads a Firestore {@link Query} from local cache, identified by the given name.
|
1040 | *
|
1041 | * The named queries are packaged into bundles on the server side (along
|
1042 | * with resulting documents), and loaded to local cache using `loadBundle`. Once in local
|
1043 | * cache, use this method to extract a {@link Query} by name.
|
1044 | */
|
1045 | export declare function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;
|
1046 | /**
|
1047 | * For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1,
|
1048 | * 'bar.qux': T2}). Intersect them together to make a single map containing
|
1049 | * all possible keys that are all marked as optional
|
1050 | */
|
1051 | export declare type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{
|
1052 | [K in keyof T & string]: ChildUpdateFields<K, T[K]>;
|
1053 | }[keyof T & string]>;
|
1054 | /**
|
1055 | * Attaches a listener for `DocumentSnapshot` events. You may either pass
|
1056 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1057 | * object with `next` and `error` callbacks.
|
1058 | *
|
1059 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1060 | * never be called because the snapshot stream is never-ending.
|
1061 | *
|
1062 | * @param reference - A reference to the document to listen to.
|
1063 | * @param observer - A single object containing `next` and `error` callbacks.
|
1064 | * @returns An unsubscribe function that can be called to cancel
|
1065 | * the snapshot listener.
|
1066 | */
|
1067 | export declare function onSnapshot<T>(reference: DocumentReference<T>, observer: {
|
1068 | next?: (snapshot: DocumentSnapshot<T>) => void;
|
1069 | error?: (error: FirestoreError) => void;
|
1070 | complete?: () => void;
|
1071 | }): Unsubscribe;
|
1072 | /**
|
1073 | * Attaches a listener for `DocumentSnapshot` events. You may either pass
|
1074 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1075 | * object with `next` and `error` callbacks.
|
1076 | *
|
1077 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1078 | * never be called because the snapshot stream is never-ending.
|
1079 | *
|
1080 | * @param reference - A reference to the document to listen to.
|
1081 | * @param options - Options controlling the listen behavior.
|
1082 | * @param observer - A single object containing `next` and `error` callbacks.
|
1083 | * @returns An unsubscribe function that can be called to cancel
|
1084 | * the snapshot listener.
|
1085 | */
|
1086 | export declare function onSnapshot<T>(reference: DocumentReference<T>, options: SnapshotListenOptions, observer: {
|
1087 | next?: (snapshot: DocumentSnapshot<T>) => void;
|
1088 | error?: (error: FirestoreError) => void;
|
1089 | complete?: () => void;
|
1090 | }): Unsubscribe;
|
1091 | /**
|
1092 | * Attaches a listener for `DocumentSnapshot` events. You may either pass
|
1093 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1094 | * object with `next` and `error` callbacks.
|
1095 | *
|
1096 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1097 | * never be called because the snapshot stream is never-ending.
|
1098 | *
|
1099 | * @param reference - A reference to the document to listen to.
|
1100 | * @param onNext - A callback to be called every time a new `DocumentSnapshot`
|
1101 | * is available.
|
1102 | * @param onError - A callback to be called if the listen fails or is
|
1103 | * cancelled. No further callbacks will occur.
|
1104 | * @param onCompletion - Can be provided, but will not be called since streams are
|
1105 | * never ending.
|
1106 | * @returns An unsubscribe function that can be called to cancel
|
1107 | * the snapshot listener.
|
1108 | */
|
1109 | export declare function onSnapshot<T>(reference: DocumentReference<T>, onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1110 | /**
|
1111 | * Attaches a listener for `DocumentSnapshot` events. You may either pass
|
1112 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1113 | * object with `next` and `error` callbacks.
|
1114 | *
|
1115 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1116 | * never be called because the snapshot stream is never-ending.
|
1117 | *
|
1118 | * @param reference - A reference to the document to listen to.
|
1119 | * @param options - Options controlling the listen behavior.
|
1120 | * @param onNext - A callback to be called every time a new `DocumentSnapshot`
|
1121 | * is available.
|
1122 | * @param onError - A callback to be called if the listen fails or is
|
1123 | * cancelled. No further callbacks will occur.
|
1124 | * @param onCompletion - Can be provided, but will not be called since streams are
|
1125 | * never ending.
|
1126 | * @returns An unsubscribe function that can be called to cancel
|
1127 | * the snapshot listener.
|
1128 | */
|
1129 | export declare function onSnapshot<T>(reference: DocumentReference<T>, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1130 | /**
|
1131 | * Attaches a listener for `QuerySnapshot` events. You may either pass
|
1132 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1133 | * object with `next` and `error` callbacks. The listener can be cancelled by
|
1134 | * calling the function that is returned when `onSnapshot` is called.
|
1135 | *
|
1136 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1137 | * never be called because the snapshot stream is never-ending.
|
1138 | *
|
1139 | * @param query - The query to listen to.
|
1140 | * @param observer - A single object containing `next` and `error` callbacks.
|
1141 | * @returns An unsubscribe function that can be called to cancel
|
1142 | * the snapshot listener.
|
1143 | */
|
1144 | export declare function onSnapshot<T>(query: Query<T>, observer: {
|
1145 | next?: (snapshot: QuerySnapshot<T>) => void;
|
1146 | error?: (error: FirestoreError) => void;
|
1147 | complete?: () => void;
|
1148 | }): Unsubscribe;
|
1149 | /**
|
1150 | * Attaches a listener for `QuerySnapshot` events. You may either pass
|
1151 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1152 | * object with `next` and `error` callbacks. The listener can be cancelled by
|
1153 | * calling the function that is returned when `onSnapshot` is called.
|
1154 | *
|
1155 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1156 | * never be called because the snapshot stream is never-ending.
|
1157 | *
|
1158 | * @param query - The query to listen to.
|
1159 | * @param options - Options controlling the listen behavior.
|
1160 | * @param observer - A single object containing `next` and `error` callbacks.
|
1161 | * @returns An unsubscribe function that can be called to cancel
|
1162 | * the snapshot listener.
|
1163 | */
|
1164 | export declare function onSnapshot<T>(query: Query<T>, options: SnapshotListenOptions, observer: {
|
1165 | next?: (snapshot: QuerySnapshot<T>) => void;
|
1166 | error?: (error: FirestoreError) => void;
|
1167 | complete?: () => void;
|
1168 | }): Unsubscribe;
|
1169 | /**
|
1170 | * Attaches a listener for `QuerySnapshot` events. You may either pass
|
1171 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1172 | * object with `next` and `error` callbacks. The listener can be cancelled by
|
1173 | * calling the function that is returned when `onSnapshot` is called.
|
1174 | *
|
1175 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1176 | * never be called because the snapshot stream is never-ending.
|
1177 | *
|
1178 | * @param query - The query to listen to.
|
1179 | * @param onNext - A callback to be called every time a new `QuerySnapshot`
|
1180 | * is available.
|
1181 | * @param onCompletion - Can be provided, but will not be called since streams are
|
1182 | * never ending.
|
1183 | * @param onError - A callback to be called if the listen fails or is
|
1184 | * cancelled. No further callbacks will occur.
|
1185 | * @returns An unsubscribe function that can be called to cancel
|
1186 | * the snapshot listener.
|
1187 | */
|
1188 | export declare function onSnapshot<T>(query: Query<T>, onNext: (snapshot: QuerySnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1189 | /**
|
1190 | * Attaches a listener for `QuerySnapshot` events. You may either pass
|
1191 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1192 | * object with `next` and `error` callbacks. The listener can be cancelled by
|
1193 | * calling the function that is returned when `onSnapshot` is called.
|
1194 | *
|
1195 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1196 | * never be called because the snapshot stream is never-ending.
|
1197 | *
|
1198 | * @param query - The query to listen to.
|
1199 | * @param options - Options controlling the listen behavior.
|
1200 | * @param onNext - A callback to be called every time a new `QuerySnapshot`
|
1201 | * is available.
|
1202 | * @param onCompletion - Can be provided, but will not be called since streams are
|
1203 | * never ending.
|
1204 | * @param onError - A callback to be called if the listen fails or is
|
1205 | * cancelled. No further callbacks will occur.
|
1206 | * @returns An unsubscribe function that can be called to cancel
|
1207 | * the snapshot listener.
|
1208 | */
|
1209 | export declare function onSnapshot<T>(query: Query<T>, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1210 | /**
|
1211 | * Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync
|
1212 | * event indicates that all listeners affected by a given change have fired,
|
1213 | * even if a single server-generated change affects multiple listeners.
|
1214 | *
|
1215 | * NOTE: The snapshots-in-sync event only indicates that listeners are in sync
|
1216 | * with each other, but does not relate to whether those snapshots are in sync
|
1217 | * with the server. Use SnapshotMetadata in the individual listeners to
|
1218 | * determine if a snapshot is from the cache or the server.
|
1219 | *
|
1220 | * @param firestore - The instance of Firestore for synchronizing snapshots.
|
1221 | * @param observer - A single object containing `next` and `error` callbacks.
|
1222 | * @returns An unsubscribe function that can be called to cancel the snapshot
|
1223 | * listener.
|
1224 | */
|
1225 | export declare function onSnapshotsInSync(firestore: Firestore, observer: {
|
1226 | next?: (value: void) => void;
|
1227 | error?: (error: FirestoreError) => void;
|
1228 | complete?: () => void;
|
1229 | }): Unsubscribe;
|
1230 | /**
|
1231 | * Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync
|
1232 | * event indicates that all listeners affected by a given change have fired,
|
1233 | * even if a single server-generated change affects multiple listeners.
|
1234 | *
|
1235 | * NOTE: The snapshots-in-sync event only indicates that listeners are in sync
|
1236 | * with each other, but does not relate to whether those snapshots are in sync
|
1237 | * with the server. Use `SnapshotMetadata` in the individual listeners to
|
1238 | * determine if a snapshot is from the cache or the server.
|
1239 | *
|
1240 | * @param firestore - The `Firestore` instance for synchronizing snapshots.
|
1241 | * @param onSync - A callback to be called every time all snapshot listeners are
|
1242 | * in sync with each other.
|
1243 | * @returns An unsubscribe function that can be called to cancel the snapshot
|
1244 | * listener.
|
1245 | */
|
1246 | export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe;
|
1247 | /**
|
1248 | * Creates a {@link QueryConstraint} that sorts the query result by the
|
1249 | * specified field, optionally in descending order instead of ascending.
|
1250 | *
|
1251 | * @param fieldPath - The field to sort by.
|
1252 | * @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
1253 | * not specified, order will be ascending.
|
1254 | * @returns The created {@link Query}.
|
1255 | */
|
1256 | export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryConstraint;
|
1257 | /**
|
1258 | * The direction of a {@link orderBy} clause is specified as 'desc' or 'asc'
|
1259 | * (descending or ascending).
|
1260 | */
|
1261 | export declare type OrderByDirection = 'desc' | 'asc';
|
1262 | /**
|
1263 | * Similar to Typescript's `Partial<T>`, but allows nested fields to be
|
1264 | * omitted and FieldValues to be passed in as property values.
|
1265 | */
|
1266 | export declare type PartialWithFieldValue<T> = T extends Primitive ? T : T extends {} ? {
|
1267 | [K in keyof T]?: PartialWithFieldValue<T[K]> | FieldValue;
|
1268 | } : Partial<T>;
|
1269 | /**
|
1270 | * Settings that can be passed to `enableIndexedDbPersistence()` to configure
|
1271 | * Firestore persistence.
|
1272 | */
|
1273 | export declare interface PersistenceSettings {
|
1274 | /**
|
1275 | * Whether to force enable persistence for the client. This cannot be used
|
1276 | * with multi-tab synchronization and is primarily intended for use with Web
|
1277 | * Workers. Setting this to `true` will enable persistence, but cause other
|
1278 | * tabs using persistence to fail.
|
1279 | */
|
1280 | forceOwnership?: boolean;
|
1281 | }
|
1282 | /**
|
1283 | * These types primarily exist to support the `UpdateData`,
|
1284 | * `WithFieldValue`, and `PartialWithFieldValue` types and are not consumed
|
1285 | * directly by the end developer.
|
1286 | */
|
1287 | /** Primitive types. */
|
1288 | export declare type Primitive = string | number | boolean | undefined | null;
|
1289 | /**
|
1290 | * A `Query` refers to a query which you can read or listen to. You can also
|
1291 | * construct refined `Query` objects by adding filters and ordering.
|
1292 | */
|
1293 | export declare class Query<T = DocumentData> {
|
1294 | /**
|
1295 | * If provided, the `FirestoreDataConverter` associated with this instance.
|
1296 | */
|
1297 | readonly converter: FirestoreDataConverter<T> | null;
|
1298 | /** The type of this Firestore reference. */
|
1299 | readonly type: 'query' | 'collection';
|
1300 | /**
|
1301 | * The `Firestore` instance for the Firestore database (useful for performing
|
1302 | * transactions, etc.).
|
1303 | */
|
1304 | readonly firestore: Firestore;
|
1305 | protected constructor();
|
1306 | /**
|
1307 | * Removes the current converter.
|
1308 | *
|
1309 | * @param converter - `null` removes the current converter.
|
1310 | * @returns A `Query<DocumentData>` that does not use a converter.
|
1311 | */
|
1312 | withConverter(converter: null): Query<DocumentData>;
|
1313 | /**
|
1314 | * Applies a custom data converter to this query, allowing you to use your own
|
1315 | * custom model objects with Firestore. When you call {@link getDocs} with
|
1316 | * the returned query, the provided converter will convert between Firestore
|
1317 | * data and your custom type `U`.
|
1318 | *
|
1319 | * @param converter - Converts objects to and from Firestore.
|
1320 | * @returns A `Query<U>` that uses the provided converter.
|
1321 | */
|
1322 | withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
|
1323 | }
|
1324 | /**
|
1325 | * Creates a new immutable instance of {@link Query} that is extended to also include
|
1326 | * additional query constraints.
|
1327 | *
|
1328 | * @param query - The {@link Query} instance to use as a base for the new constraints.
|
1329 | * @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
1330 | * @throws if any of the provided query constraints cannot be combined with the
|
1331 | * existing or new constraints.
|
1332 | */
|
1333 | export declare function query<T>(query: Query<T>, ...queryConstraints: QueryConstraint[]): Query<T>;
|
1334 | /**
|
1335 | * A `QueryConstraint` is used to narrow the set of documents returned by a
|
1336 | * Firestore query. `QueryConstraint`s are created by invoking {@link where},
|
1337 | * {@link orderBy}, {@link (startAt:1)}, {@link (startAfter:1)}, {@link
|
1338 | * endBefore:1}, {@link (endAt:1)}, {@link limit} or {@link limitToLast} and
|
1339 | * can then be passed to {@link query} to create a new query instance that
|
1340 | * also contains this `QueryConstraint`.
|
1341 | */
|
1342 | export declare abstract class QueryConstraint {
|
1343 | /** The type of this query constraints */
|
1344 | abstract readonly type: QueryConstraintType;
|
1345 | }
|
1346 | /** Describes the different query constraints available in this SDK. */
|
1347 | export declare type QueryConstraintType = 'where' | 'orderBy' | 'limit' | 'limitToLast' | 'startAt' | 'startAfter' | 'endAt' | 'endBefore';
|
1348 | /**
|
1349 | * A `QueryDocumentSnapshot` contains data read from a document in your
|
1350 | * Firestore database as part of a query. The document is guaranteed to exist
|
1351 | * and its data can be extracted with `.data()` or `.get(<field>)` to get a
|
1352 | * specific field.
|
1353 | *
|
1354 | * A `QueryDocumentSnapshot` offers the same API surface as a
|
1355 | * `DocumentSnapshot`. Since query results contain only existing documents, the
|
1356 | * `exists` property will always be true and `data()` will never return
|
1357 | * 'undefined'.
|
1358 | */
|
1359 | export declare class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
|
1360 | /**
|
1361 | * Retrieves all fields in the document as an `Object`.
|
1362 | *
|
1363 | * By default, `FieldValue.serverTimestamp()` values that have not yet been
|
1364 | * set to their final value will be returned as `null`. You can override
|
1365 | * this by passing an options object.
|
1366 | *
|
1367 | * @override
|
1368 | * @param options - An options object to configure how data is retrieved from
|
1369 | * the snapshot (for example the desired behavior for server timestamps that
|
1370 | * have not yet been set to their final value).
|
1371 | * @returns An `Object` containing all fields in the document.
|
1372 | */
|
1373 | data(options?: SnapshotOptions): T;
|
1374 | }
|
1375 | /**
|
1376 | * Returns true if the provided queries point to the same collection and apply
|
1377 | * the same constraints.
|
1378 | *
|
1379 | * @param left - A `Query` to compare.
|
1380 | * @param right - A `Query` to compare.
|
1381 | * @returns true if the references point to the same location in the same
|
1382 | * Firestore database.
|
1383 | */
|
1384 | export declare function queryEqual<T>(left: Query<T>, right: Query<T>): boolean;
|
1385 | /**
|
1386 | * A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects
|
1387 | * representing the results of a query. The documents can be accessed as an
|
1388 | * array via the `docs` property or enumerated using the `forEach` method. The
|
1389 | * number of documents can be determined via the `empty` and `size`
|
1390 | * properties.
|
1391 | */
|
1392 | export declare class QuerySnapshot<T = DocumentData> {
|
1393 | /**
|
1394 | * Metadata about this snapshot, concerning its source and if it has local
|
1395 | * modifications.
|
1396 | */
|
1397 | readonly metadata: SnapshotMetadata;
|
1398 | /**
|
1399 | * The query on which you called `get` or `onSnapshot` in order to get this
|
1400 | * `QuerySnapshot`.
|
1401 | */
|
1402 | readonly query: Query<T>;
|
1403 | private constructor();
|
1404 | /** An array of all the documents in the `QuerySnapshot`. */
|
1405 | get docs(): Array<QueryDocumentSnapshot<T>>;
|
1406 | /** The number of documents in the `QuerySnapshot`. */
|
1407 | get size(): number;
|
1408 | /** True if there are no documents in the `QuerySnapshot`. */
|
1409 | get empty(): boolean;
|
1410 | /**
|
1411 | * Enumerates all of the documents in the `QuerySnapshot`.
|
1412 | *
|
1413 | * @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
1414 | * each document in the snapshot.
|
1415 | * @param thisArg - The `this` binding for the callback.
|
1416 | */
|
1417 | forEach(callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?: unknown): void;
|
1418 | /**
|
1419 | * Returns an array of the documents changes since the last snapshot. If this
|
1420 | * is the first snapshot, all documents will be in the list as 'added'
|
1421 | * changes.
|
1422 | *
|
1423 | * @param options - `SnapshotListenOptions` that control whether metadata-only
|
1424 | * changes (i.e. only `DocumentSnapshot.metadata` changed) should trigger
|
1425 | * snapshot events.
|
1426 | */
|
1427 | docChanges(options?: SnapshotListenOptions): Array<DocumentChange<T>>;
|
1428 | }
|
1429 | /**
|
1430 | * Returns true if the provided references are equal.
|
1431 | *
|
1432 | * @param left - A reference to compare.
|
1433 | * @param right - A reference to compare.
|
1434 | * @returns true if the references point to the same location in the same
|
1435 | * Firestore database.
|
1436 | */
|
1437 | export declare function refEqual<T>(left: DocumentReference<T> | CollectionReference<T>, right: DocumentReference<T> | CollectionReference<T>): boolean;
|
1438 | /* Excluded from this release type: _ResourcePath */
|
1439 | /**
|
1440 | * Executes the given `updateFunction` and then attempts to commit the changes
|
1441 | * applied within the transaction. If any document read within the transaction
|
1442 | * has changed, Cloud Firestore retries the `updateFunction`. If it fails to
|
1443 | * commit after 5 attempts, the transaction fails.
|
1444 | *
|
1445 | * The maximum number of writes allowed in a single transaction is 500.
|
1446 | *
|
1447 | * @param firestore - A reference to the Firestore database to run this
|
1448 | * transaction against.
|
1449 | * @param updateFunction - The function to execute within the transaction
|
1450 | * context.
|
1451 | * @returns If the transaction completed successfully or was explicitly aborted
|
1452 | * (the `updateFunction` returned a failed promise), the promise returned by the
|
1453 | * `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
1454 | * rejected promise with the corresponding failure error is returned.
|
1455 | */
|
1456 | export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>): Promise<T>;
|
1457 | /**
|
1458 | * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
1459 | * include a server-generated timestamp in the written data.
|
1460 | */
|
1461 | export declare function serverTimestamp(): FieldValue;
|
1462 | /**
|
1463 | * Writes to the document referred to by this `DocumentReference`. If the
|
1464 | * document does not yet exist, it will be created.
|
1465 | *
|
1466 | * @param reference - A reference to the document to write.
|
1467 | * @param data - A map of the fields and values for the document.
|
1468 | * @returns A `Promise` resolved once the data has been successfully written
|
1469 | * to the backend (note that it won't resolve while you're offline).
|
1470 | */
|
1471 | export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFieldValue<T>): Promise<void>;
|
1472 | /**
|
1473 | * Writes to the document referred to by the specified `DocumentReference`. If
|
1474 | * the document does not yet exist, it will be created. If you provide `merge`
|
1475 | * or `mergeFields`, the provided data can be merged into an existing document.
|
1476 | *
|
1477 | * @param reference - A reference to the document to write.
|
1478 | * @param data - A map of the fields and values for the document.
|
1479 | * @param options - An object to configure the set behavior.
|
1480 | * @returns A Promise resolved once the data has been successfully written
|
1481 | * to the backend (note that it won't resolve while you're offline).
|
1482 | */
|
1483 | export declare function setDoc<T>(reference: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): Promise<void>;
|
1484 | /**
|
1485 | * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
1486 | *
|
1487 | * @param logLevel - The verbosity you set for activity and error logging. Can
|
1488 | * be any of the following values:
|
1489 | *
|
1490 | * <ul>
|
1491 | * <li>`debug` for the most verbose logging level, primarily for
|
1492 | * debugging.</li>
|
1493 | * <li>`error` to log errors only.</li>
|
1494 | * <li><code>`silent` to turn off logging.</li>
|
1495 | * </ul>
|
1496 | */
|
1497 | export declare function setLogLevel(logLevel: LogLevel): void;
|
1498 | /**
|
1499 | * An options object that configures the behavior of {@link @firebase/firestore/lite#(setDoc:1)}, {@link
|
1500 | * @firebase/firestore/lite#(WriteBatch.set:1)} and {@link @firebase/firestore/lite#(Transaction.set:1)} calls. These calls can be
|
1501 | * configured to perform granular merges instead of overwriting the target
|
1502 | * documents in their entirety by providing a `SetOptions` with `merge: true`.
|
1503 | *
|
1504 | * @param merge - Changes the behavior of a `setDoc()` call to only replace the
|
1505 | * values specified in its data argument. Fields omitted from the `setDoc()`
|
1506 | * call remain untouched.
|
1507 | * @param mergeFields - Changes the behavior of `setDoc()` calls to only replace
|
1508 | * the specified field paths. Any field path that is not specified is ignored
|
1509 | * and remains untouched.
|
1510 | */
|
1511 | export declare type SetOptions = {
|
1512 | readonly merge?: boolean;
|
1513 | } | {
|
1514 | readonly mergeFields?: Array<string | FieldPath>;
|
1515 | };
|
1516 | /**
|
1517 | * Returns true if the provided snapshots are equal.
|
1518 | *
|
1519 | * @param left - A snapshot to compare.
|
1520 | * @param right - A snapshot to compare.
|
1521 | * @returns true if the snapshots are equal.
|
1522 | */
|
1523 | export declare function snapshotEqual<T>(left: DocumentSnapshot<T> | QuerySnapshot<T>, right: DocumentSnapshot<T> | QuerySnapshot<T>): boolean;
|
1524 | /**
|
1525 | * An options object that can be passed to {@link (onSnapshot:1)} and {@link
|
1526 | * QuerySnapshot.docChanges} to control which types of changes to include in the
|
1527 | * result set.
|
1528 | */
|
1529 | export declare interface SnapshotListenOptions {
|
1530 | /**
|
1531 | * Include a change even if only the metadata of the query or of a document
|
1532 | * changed. Default is false.
|
1533 | */
|
1534 | readonly includeMetadataChanges?: boolean;
|
1535 | }
|
1536 | /**
|
1537 | * Metadata about a snapshot, describing the state of the snapshot.
|
1538 | */
|
1539 | export declare class SnapshotMetadata {
|
1540 | /**
|
1541 | * True if the snapshot contains the result of local writes (for example
|
1542 | * `set()` or `update()` calls) that have not yet been committed to the
|
1543 | * backend. If your listener has opted into metadata updates (via
|
1544 | * `SnapshotListenOptions`) you will receive another snapshot with
|
1545 | * `hasPendingWrites` equal to false once the writes have been committed to
|
1546 | * the backend.
|
1547 | */
|
1548 | readonly hasPendingWrites: boolean;
|
1549 | /**
|
1550 | * True if the snapshot was created from cached data rather than guaranteed
|
1551 | * up-to-date server data. If your listener has opted into metadata updates
|
1552 | * (via `SnapshotListenOptions`) you will receive another snapshot with
|
1553 | * `fromCache` set to false once the client has received up-to-date data from
|
1554 | * the backend.
|
1555 | */
|
1556 | readonly fromCache: boolean;
|
1557 | private constructor();
|
1558 | /**
|
1559 | * Returns true if this `SnapshotMetadata` is equal to the provided one.
|
1560 | *
|
1561 | * @param other - The `SnapshotMetadata` to compare against.
|
1562 | * @returns true if this `SnapshotMetadata` is equal to the provided one.
|
1563 | */
|
1564 | isEqual(other: SnapshotMetadata): boolean;
|
1565 | }
|
1566 | /**
|
1567 | * Options that configure how data is retrieved from a `DocumentSnapshot` (for
|
1568 | * example the desired behavior for server timestamps that have not yet been set
|
1569 | * to their final value).
|
1570 | */
|
1571 | export declare interface SnapshotOptions {
|
1572 | /**
|
1573 | * If set, controls the return value for server timestamps that have not yet
|
1574 | * been set to their final value.
|
1575 | *
|
1576 | * By specifying 'estimate', pending server timestamps return an estimate
|
1577 | * based on the local clock. This estimate will differ from the final value
|
1578 | * and cause these values to change once the server result becomes available.
|
1579 | *
|
1580 | * By specifying 'previous', pending timestamps will be ignored and return
|
1581 | * their previous value instead.
|
1582 | *
|
1583 | * If omitted or set to 'none', `null` will be returned by default until the
|
1584 | * server value becomes available.
|
1585 | */
|
1586 | readonly serverTimestamps?: 'estimate' | 'previous' | 'none';
|
1587 | }
|
1588 | /**
|
1589 | * Creates a {@link QueryConstraint} that modifies the result set to start after the
|
1590 | * provided document (exclusive). The starting position is relative to the order
|
1591 | * of the query. The document must contain all of the fields provided in the
|
1592 | * orderBy of the query.
|
1593 | *
|
1594 | * @param snapshot - The snapshot of the document to start after.
|
1595 | * @returns A {@link QueryConstraint} to pass to `query()`
|
1596 | */
|
1597 | export declare function startAfter(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
|
1598 | /**
|
1599 | * Creates a {@link QueryConstraint} that modifies the result set to start after the
|
1600 | * provided fields relative to the order of the query. The order of the field
|
1601 | * values must match the order of the order by clauses of the query.
|
1602 | *
|
1603 | * @param fieldValues - The field values to start this query after, in order
|
1604 | * of the query's order by.
|
1605 | * @returns A {@link QueryConstraint} to pass to `query()`
|
1606 | */
|
1607 | export declare function startAfter(...fieldValues: unknown[]): QueryConstraint;
|
1608 | /**
|
1609 | * Creates a {@link QueryConstraint} that modifies the result set to start at the
|
1610 | * provided document (inclusive). The starting position is relative to the order
|
1611 | * of the query. The document must contain all of the fields provided in the
|
1612 | * `orderBy` of this query.
|
1613 | *
|
1614 | * @param snapshot - The snapshot of the document to start at.
|
1615 | * @returns A {@link QueryConstraint} to pass to `query()`.
|
1616 | */
|
1617 | export declare function startAt(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
|
1618 | /**
|
1619 | * Creates a {@link QueryConstraint} that modifies the result set to start at the
|
1620 | * provided fields relative to the order of the query. The order of the field
|
1621 | * values must match the order of the order by clauses of the query.
|
1622 | *
|
1623 | * @param fieldValues - The field values to start this query at, in order
|
1624 | * of the query's order by.
|
1625 | * @returns A {@link QueryConstraint} to pass to `query()`.
|
1626 | */
|
1627 | export declare function startAt(...fieldValues: unknown[]): QueryConstraint;
|
1628 | /**
|
1629 | * Represents the state of bundle loading tasks.
|
1630 | *
|
1631 | * Both 'Error' and 'Success' are sinking state: task will abort or complete and there will
|
1632 | * be no more updates after they are reported.
|
1633 | */
|
1634 | export declare type TaskState = 'Error' | 'Running' | 'Success';
|
1635 | /**
|
1636 | * Terminates the provided {@link Firestore} instance.
|
1637 | *
|
1638 | * After calling `terminate()` only the `clearIndexedDbPersistence()` function
|
1639 | * may be used. Any other function will throw a `FirestoreError`.
|
1640 | *
|
1641 | * To restart after termination, create a new instance of FirebaseFirestore with
|
1642 | * {@link getFirestore}.
|
1643 | *
|
1644 | * Termination does not cancel any pending writes, and any promises that are
|
1645 | * awaiting a response from the server will not be resolved. If you have
|
1646 | * persistence enabled, the next time you start this instance, it will resume
|
1647 | * sending these writes to the server.
|
1648 | *
|
1649 | * Note: Under normal circumstances, calling `terminate()` is not required. This
|
1650 | * function is useful only when you want to force this instance to release all
|
1651 | * of its resources or in combination with `clearIndexedDbPersistence()` to
|
1652 | * ensure that all local state is destroyed between test runs.
|
1653 | *
|
1654 | * @returns A `Promise` that is resolved when the instance has been successfully
|
1655 | * terminated.
|
1656 | */
|
1657 | export declare function terminate(firestore: Firestore): Promise<void>;
|
1658 | /**
|
1659 | * @license
|
1660 | * Copyright 2017 Google LLC
|
1661 | *
|
1662 | * Licensed under the Apache License, Version 2.0 (the "License");
|
1663 | * you may not use this file except in compliance with the License.
|
1664 | * You may obtain a copy of the License at
|
1665 | *
|
1666 | * http://www.apache.org/licenses/LICENSE-2.0
|
1667 | *
|
1668 | * Unless required by applicable law or agreed to in writing, software
|
1669 | * distributed under the License is distributed on an "AS IS" BASIS,
|
1670 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
1671 | * See the License for the specific language governing permissions and
|
1672 | * limitations under the License.
|
1673 | */
|
1674 | /**
|
1675 | * A `Timestamp` represents a point in time independent of any time zone or
|
1676 | * calendar, represented as seconds and fractions of seconds at nanosecond
|
1677 | * resolution in UTC Epoch time.
|
1678 | *
|
1679 | * It is encoded using the Proleptic Gregorian Calendar which extends the
|
1680 | * Gregorian calendar backwards to year one. It is encoded assuming all minutes
|
1681 | * are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second
|
1682 | * table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
|
1683 | * 9999-12-31T23:59:59.999999999Z.
|
1684 | *
|
1685 | * For examples and further specifications, refer to the
|
1686 | * {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
1687 | */
|
1688 | export declare class Timestamp {
|
1689 | /**
|
1690 | * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
|
1691 | */
|
1692 | readonly seconds: number;
|
1693 | /**
|
1694 | * The fractions of a second at nanosecond resolution.*
|
1695 | */
|
1696 | readonly nanoseconds: number;
|
1697 | /**
|
1698 | * Creates a new timestamp with the current date, with millisecond precision.
|
1699 | *
|
1700 | * @returns a new timestamp representing the current date.
|
1701 | */
|
1702 | static now(): Timestamp;
|
1703 | /**
|
1704 | * Creates a new timestamp from the given date.
|
1705 | *
|
1706 | * @param date - The date to initialize the `Timestamp` from.
|
1707 | * @returns A new `Timestamp` representing the same point in time as the given
|
1708 | * date.
|
1709 | */
|
1710 | static fromDate(date: Date): Timestamp;
|
1711 | /**
|
1712 | * Creates a new timestamp from the given number of milliseconds.
|
1713 | *
|
1714 | * @param milliseconds - Number of milliseconds since Unix epoch
|
1715 | * 1970-01-01T00:00:00Z.
|
1716 | * @returns A new `Timestamp` representing the same point in time as the given
|
1717 | * number of milliseconds.
|
1718 | */
|
1719 | static fromMillis(milliseconds: number): Timestamp;
|
1720 | /**
|
1721 | * Creates a new timestamp.
|
1722 | *
|
1723 | * @param seconds - The number of seconds of UTC time since Unix epoch
|
1724 | * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
1725 | * 9999-12-31T23:59:59Z inclusive.
|
1726 | * @param nanoseconds - The non-negative fractions of a second at nanosecond
|
1727 | * resolution. Negative second values with fractions must still have
|
1728 | * non-negative nanoseconds values that count forward in time. Must be
|
1729 | * from 0 to 999,999,999 inclusive.
|
1730 | */
|
1731 | constructor(
|
1732 | |
1733 |
|
1734 |
|
1735 | seconds: number,
|
1736 | |
1737 |
|
1738 |
|
1739 | nanoseconds: number);
|
1740 | /**
|
1741 | * Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
1742 | * causes a loss of precision since `Date` objects only support millisecond
|
1743 | * precision.
|
1744 | *
|
1745 | * @returns JavaScript `Date` object representing the same point in time as
|
1746 | * this `Timestamp`, with millisecond precision.
|
1747 | */
|
1748 | toDate(): Date;
|
1749 | /**
|
1750 | * Converts a `Timestamp` to a numeric timestamp (in milliseconds since
|
1751 | * epoch). This operation causes a loss of precision.
|
1752 | *
|
1753 | * @returns The point in time corresponding to this timestamp, represented as
|
1754 | * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
|
1755 | */
|
1756 | toMillis(): number;
|
1757 | /**
|
1758 | * Returns true if this `Timestamp` is equal to the provided one.
|
1759 | *
|
1760 | * @param other - The `Timestamp` to compare against.
|
1761 | * @returns true if this `Timestamp` is equal to the provided one.
|
1762 | */
|
1763 | isEqual(other: Timestamp): boolean;
|
1764 | /** Returns a textual representation of this `Timestamp`. */
|
1765 | toString(): string;
|
1766 | /** Returns a JSON-serializable representation of this `Timestamp`. */
|
1767 | toJSON(): {
|
1768 | seconds: number;
|
1769 | nanoseconds: number;
|
1770 | };
|
1771 | /**
|
1772 | * Converts this object to a primitive string, which allows `Timestamp` objects
|
1773 | * to be compared using the `>`, `<=`, `>=` and `>` operators.
|
1774 | */
|
1775 | valueOf(): string;
|
1776 | }
|
1777 | /**
|
1778 | * A reference to a transaction.
|
1779 | *
|
1780 | * The `Transaction` object passed to a transaction's `updateFunction` provides
|
1781 | * the methods to read and write data within the transaction context. See
|
1782 | * {@link runTransaction}.
|
1783 | */
|
1784 | export declare class Transaction {
|
1785 | private constructor();
|
1786 | /**
|
1787 | * Reads the document referenced by the provided {@link DocumentReference}.
|
1788 | *
|
1789 | * @param documentRef - A reference to the document to be read.
|
1790 | * @returns A `DocumentSnapshot` with the read data.
|
1791 | */
|
1792 | get<T>(documentRef: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
1793 | /**
|
1794 | * Writes to the document referred to by the provided {@link
|
1795 | * DocumentReference}. If the document does not exist yet, it will be created.
|
1796 | *
|
1797 | * @param documentRef - A reference to the document to be set.
|
1798 | * @param data - An object of the fields and values for the document.
|
1799 | * @returns This `Transaction` instance. Used for chaining method calls.
|
1800 | */
|
1801 | set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): this;
|
1802 | /**
|
1803 | * Writes to the document referred to by the provided {@link
|
1804 | * DocumentReference}. If the document does not exist yet, it will be created.
|
1805 | * If you provide `merge` or `mergeFields`, the provided data can be merged
|
1806 | * into an existing document.
|
1807 | *
|
1808 | * @param documentRef - A reference to the document to be set.
|
1809 | * @param data - An object of the fields and values for the document.
|
1810 | * @param options - An object to configure the set behavior.
|
1811 | * @returns This `Transaction` instance. Used for chaining method calls.
|
1812 | */
|
1813 | set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): this;
|
1814 | /**
|
1815 | * Updates fields in the document referred to by the provided {@link
|
1816 | * DocumentReference}. The update will fail if applied to a document that does
|
1817 | * not exist.
|
1818 | *
|
1819 | * @param documentRef - A reference to the document to be updated.
|
1820 | * @param data - An object containing the fields and values with which to
|
1821 | update the document. Fields can contain dots to reference nested fields
|
1822 | within the document.
|
1823 | * @returns This `Transaction` instance. Used for chaining method calls.
|
1824 | */
|
1825 | update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): this;
|
1826 | /**
|
1827 | * Updates fields in the document referred to by the provided {@link
|
1828 | * DocumentReference}. The update will fail if applied to a document that does
|
1829 | * not exist.
|
1830 | *
|
1831 | * Nested fields can be updated by providing dot-separated field path
|
1832 | * strings or by providing `FieldPath` objects.
|
1833 | *
|
1834 | * @param documentRef - A reference to the document to be updated.
|
1835 | * @param field - The first field to update.
|
1836 | * @param value - The first value.
|
1837 | * @param moreFieldsAndValues - Additional key/value pairs.
|
1838 | * @returns This `Transaction` instance. Used for chaining method calls.
|
1839 | */
|
1840 | update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): this;
|
1841 | /**
|
1842 | * Deletes the document referred to by the provided {@link DocumentReference}.
|
1843 | *
|
1844 | * @param documentRef - A reference to the document to be deleted.
|
1845 | * @returns This `Transaction` instance. Used for chaining method calls.
|
1846 | */
|
1847 | delete(documentRef: DocumentReference<unknown>): this;
|
1848 | }
|
1849 | /**
|
1850 | * Given a union type `U = T1 | T2 | ...`, returns an intersected type
|
1851 | * `(T1 & T2 & ...)`.
|
1852 | *
|
1853 | * Uses distributive conditional types and inference from conditional types.
|
1854 | * This works because multiple candidates for the same type variable in
|
1855 | * contra-variant positions causes an intersection type to be inferred.
|
1856 | * https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types
|
1857 | * https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
|
1858 | */
|
1859 | export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
1860 |
|
1861 |
|
1862 |
|
1863 | export declare interface Unsubscribe {
|
1864 |
|
1865 | (): void;
|
1866 | }
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 | export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
|
1874 | [K in keyof T]?: UpdateData<T[K]> | FieldValue;
|
1875 | } & NestedUpdateFields<T> : Partial<T>;
|
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 |
|
1884 |
|
1885 |
|
1886 |
|
1887 |
|
1888 | export declare function updateDoc<T>(reference: DocumentReference<T>, data: UpdateData<T>): Promise<void>;
|
1889 |
|
1890 |
|
1891 |
|
1892 |
|
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 |
|
1898 |
|
1899 |
|
1900 |
|
1901 |
|
1902 |
|
1903 |
|
1904 | export declare function updateDoc(reference: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise<void>;
|
1905 |
|
1906 |
|
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 |
|
1916 |
|
1917 |
|
1918 |
|
1919 |
|
1920 |
|
1921 | export declare function waitForPendingWrites(firestore: Firestore): Promise<void>;
|
1922 |
|
1923 |
|
1924 |
|
1925 |
|
1926 |
|
1927 |
|
1928 |
|
1929 |
|
1930 |
|
1931 |
|
1932 |
|
1933 | export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryConstraint;
|
1934 |
|
1935 |
|
1936 |
|
1937 |
|
1938 |
|
1939 | export declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any' | 'not-in';
|
1940 |
|
1941 |
|
1942 |
|
1943 |
|
1944 | export declare type WithFieldValue<T> = T extends Primitive ? T : T extends {} ? {
|
1945 | [K in keyof T]: WithFieldValue<T[K]> | FieldValue;
|
1946 | } : Partial<T>;
|
1947 |
|
1948 |
|
1949 |
|
1950 |
|
1951 |
|
1952 |
|
1953 |
|
1954 |
|
1955 | export declare class WriteBatch {
|
1956 | private constructor();
|
1957 | /**
|
1958 | * Writes to the document referred to by the provided {@link
|
1959 | * DocumentReference}. If the document does not exist yet, it will be created.
|
1960 | *
|
1961 | * @param documentRef - A reference to the document to be set.
|
1962 | * @param data - An object of the fields and values for the document.
|
1963 | * @returns This `WriteBatch` instance. Used for chaining method calls.
|
1964 | */
|
1965 | set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): WriteBatch;
|
1966 | |
1967 |
|
1968 |
|
1969 |
|
1970 |
|
1971 |
|
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 | set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): WriteBatch;
|
1978 | |
1979 |
|
1980 |
|
1981 |
|
1982 |
|
1983 |
|
1984 |
|
1985 |
|
1986 |
|
1987 |
|
1988 |
|
1989 | update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): WriteBatch;
|
1990 | |
1991 |
|
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 |
|
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 | update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): WriteBatch;
|
2005 | |
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 | delete(documentRef: DocumentReference<unknown>): WriteBatch;
|
2012 | |
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 | commit(): Promise<void>;
|
2025 | }
|
2026 |
|
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 |
|
2032 |
|
2033 |
|
2034 |
|
2035 |
|
2036 |
|
2037 | export declare function writeBatch(firestore: Firestore): WriteBatch;
|
2038 | export {};
|