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