The Firebase Cloud Firestore service is available for the default app or a given app.
Example: Get the firestore instance for the default app:
const firestoreForDefaultApp = firebase.firestore();
Example: Get the firestore instance for a secondary app:
const otherApp = firebase.app('otherApp'); const firestoreForOtherApp = firebase.firestore(otherApp);
FirebaseApp instance for this Firebase service.
Creates a write batch, used for performing multiple writes as a single atomic operation.
The maximum number of writes allowed in a single WriteBatch is 500, but note that each usage
inside a WriteBatch counts as an additional write.
Aimed primarily at clearing up any data cached from running tests. Needs to be executed before any database calls are made.
CollectionReference instance that refers to the collection at the specified path.
collection(collectionPath: string): CollectionReference<>;
Creates and returns a new Query that includes all documents in the database that are contained in a collection or subcollection with the given collectionId.
collectionGroup(collectionId: string): Query<>;
Disables network usage for this instance. It can be re-enabled via
enableNetwork(). While the
network is disabled, any snapshot listeners or get() calls will return results from cache, and any
write operations will be queued until the network is restored.
DocumentReference instance that refers to the document at the specified path.
doc(documentPath: string): DocumentReference<>;
Re-enables use of the network for this Firestore instance after a prior call to
Loads a Firestore bundle into the local cache.
loadBundle(bundle: string): Promise<LoadBundleTaskProgress>;
Reads a Firestore Query from local cache, identified by the given name.
namedQuery(name: string): Query<>;
Executes the given
updateFunction and then attempts to commit the changes applied within the transaction.
If any document read within the transaction has changed, Cloud Firestore retries the
If it fails to commit after 5 attempts, the transaction fails.
runTransaction(updateFunction: (transaction: Transaction) => Promise<any>): Promise<any>;
Specifies custom settings to be used to configure the Firestore instance. Must be set before invoking any other methods.
Typically called to ensure a new Firestore instance is initialized before calling
Modify this Firestore instance to communicate with the Firebase Firestore emulator. This must be called before any other calls to Firebase Firestore to take effect. Do not use with production credentials as emulator traffic is not encrypted.
useEmulator(host: string, port: number): void;
Waits until all currently pending writes for the active user have been acknowledged by the backend.
Used to set the cache size to unlimited when passing to
Sets the verbosity of Cloud Firestore native device logs (debug, error, or silent).
firestore.setLogLevel(logLevel: "debug" | "error" | "silent"): void;