addDoc(reference, data) |
Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically. |
arrayRemove(elements) |
Returns a special value that can be used with setDoc() or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. |
arrayUnion(elements) |
Returns a special value that can be used with setDoc() or updateDoc() that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. |
clearIndexedDbPersistence(firestore) |
Clears the persistent storage. This includes pending writes and cached documents.Must be called while the Firestore instance is not started (after the app is terminated or when the app is first initialized). On startup, this function must be called before other functions (other than initializeFirestore() or getFirestore())). If the Firestore instance is still running, the promise will be rejected with the error code of failed-precondition .Note: clearIndexedDbPersistence() is primarily intended to help write reliable tests that use Cloud Firestore. It uses an efficient mechanism for dropping existing data but does not attempt to securely overwrite or otherwise make cached data unrecoverable. For applications that are sensitive to the disclosure of cached data in between user sessions, we strongly recommend not enabling persistence at all. |
collection(firestore, path, pathSegments) |
Gets a CollectionReference instance that refers to the collection at the specified absolute path. |
collection(reference, path, pathSegments) |
Gets a CollectionReference instance that refers to a subcollection of reference at the the specified relative path. |
collection(reference, path, pathSegments) |
Gets a CollectionReference instance that refers to a subcollection of reference at the the specified relative path. |
collectionGroup(firestore, collectionId) |
Creates and returns a new Query instance that includes all documents in the database that are contained in a collection or subcollection with the given collectionId . |
deleteDoc(reference) |
Deletes the document referred to by the specified DocumentReference . |
deleteField() |
Returns a sentinel for use with updateDoc() or setDoc() with {merge: true} to mark a field for deletion. |
disableNetwork(firestore) |
Disables network usage for this instance. It can be re-enabled via enableNetwork(). While the network is disabled, any snapshot listeners, getDoc() or getDocs() calls will return results from cache, and any write operations will be queued until the network is restored. |
doc(firestore, path, pathSegments) |
Gets a DocumentReference instance that refers to the document at the specified abosulute path. |
doc(reference, path, pathSegments) |
Gets a DocumentReference instance that refers to a document within reference at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference . |
doc(reference, path, pathSegments) |
Gets a DocumentReference instance that refers to a document within reference at the specified relative path. |
documentId() |
Returns a special sentinel FieldPath to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. |
enableIndexedDbPersistence(firestore, persistenceSettings) |
Attempts to enable persistent storage, if possible.Must be called before any other functions (other than initializeFirestore(), getFirestore() or clearIndexedDbPersistence().If this fails, enableIndexedDbPersistence() will reject the promise it returns. Note that even after this failure, the Firestore instance will remain usable, however offline persistence will be disabled.There are several reasons why this can fail, which can be identified by the code on the error.* failed-precondition: The app is already open in another browser tab. * unimplemented: The browser is incompatible with the offline persistence implementation. |
enableMultiTabIndexedDbPersistence(firestore) |
Attempts to enable multi-tab persistent storage, if possible. If enabled across all tabs, all operations share access to local persistence, including shared execution of queries and latency-compensated local document updates across all connected instances.If this fails, enableMultiTabIndexedDbPersistence() will reject the promise it returns. Note that even after this failure, the Firestore instance will remain usable, however offline persistence will be disabled.There are several reasons why this can fail, which can be identified by the code on the error.* failed-precondition: The app is already open in another browser tab and multi-tab is not enabled. * unimplemented: The browser is incompatible with the offline persistence implementation. |
enableNetwork(firestore) |
Re-enables use of the network for this Firestore instance after a prior call to disableNetwork(). |
endAt(snapshot) |
Creates a QueryConstraint that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. |
endAt(fieldValues) |
Creates a QueryConstraint that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. |
endBefore(snapshot) |
Creates a QueryConstraint that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. |
endBefore(fieldValues) |
Creates a QueryConstraint that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. |
getDoc(reference) |
Reads the document referred to by this DocumentReference .Note: getDoc() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke getDocFromCache() or getDocFromServer(). |
getDocFromCache(reference) |
Reads the document referred to by this DocumentReference from cache. Returns an error if the document is not currently cached. |
getDocFromServer(reference) |
Reads the document referred to by this DocumentReference from the server. Returns an error if the network is not available. |
getDocs(query) |
Executes the query and returns the results as a QuerySnapshot .Note: getDocs() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke getDocsFromCache() or getDocsFromServer(). |
getDocsFromCache(query) |
Executes the query and returns the results as a QuerySnapshot from cache. Returns an error if the document is not currently cached. |
getDocsFromServer(query) |
Executes the query and returns the results as a QuerySnapshot from the server. Returns an error if the network is not available. |
getFirestore(app) |
Returns the existing instance of Firestore that is associated with the provided FirebaseApp. If no instance exists, initializes a new instance with default settings. |
increment(n) |
Returns a special value that can be used with setDoc() or updateDoc() that tells the server to increment the field's current value by the given value.If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER ) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.If the current field value is not of type number , or if the field does not yet exist, the transformation sets the field to the given value. |
initializeFirestore(app, settings) |
Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other function, including getFirestore(). If the custom settings are empty, this function is equivalent to calling getFirestore(). |
limit(limit) |
Creates a QueryConstraint that only returns the first matching documents. |
limitToLast(limit) |
Creates a QueryConstraint that only returns the last matching documents.You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution. |
loadBundle(firestore, bundleData) |
Loads a Firestore bundle into the local cache. |
namedQuery(firestore, name) |
Reads a Firestore Query from local cache, identified by the given name.The named queries are packaged into bundles on the server side (along with resulting documents), and loaded to local cache using loadBundle . Once in local cache, use this method to extract a Query by name. |
onSnapshot(reference, observer) |
Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. |
onSnapshot(reference, options, observer) |
Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. |
onSnapshot(reference, onNext, onError, onCompletion) |
Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. |
onSnapshot(reference, options, onNext, onError, onCompletion) |
Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. |
onSnapshot(query, observer) |
Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. |
onSnapshot(query, options, observer) |
Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. |
onSnapshot(query, onNext, onError, onCompletion) |
Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. |
onSnapshot(query, options, onNext, onError, onCompletion) |
Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. |
onSnapshotsInSync(firestore, observer) |
Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. |
onSnapshotsInSync(firestore, onSync) |
Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. |
orderBy(fieldPath, directionStr) |
Creates a QueryConstraint that sorts the query result by the specified field, optionally in descending order instead of ascending. |
query(query, queryConstraints) |
Creates a new immutable instance of Query that is extended to also include additional query constraints. |
queryEqual(left, right) |
Returns true if the provided queries point to the same collection and apply the same constraints. |
refEqual(left, right) |
Returns true if the provided references are equal. |
runTransaction(firestore, updateFunction) |
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 updateFunction . If it fails to commit after 5 attempts, the transaction fails.The maximum number of writes allowed in a single transaction is 500. |
serverTimestamp() |
Returns a sentinel used with setDoc() or updateDoc() to include a server-generated timestamp in the written data. |
setDoc(reference, data) |
Writes to the document referred to by this DocumentReference . If the document does not yet exist, it will be created. |
setDoc(reference, data, options) |
Writes to the document referred to by the specified DocumentReference . If the document does not yet exist, it will be created. If you provide merge or mergeFields , the provided data can be merged into an existing document. |
setLogLevel(logLevel) |
Sets the verbosity of Cloud Firestore logs (debug, error, or silent). |
snapshotEqual(left, right) |
Returns true if the provided snapshots are equal. |
startAfter(snapshot) |
Creates a QueryConstraint that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. |
startAfter(fieldValues) |
Creates a QueryConstraint that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. |
startAt(snapshot) |
Creates a QueryConstraint that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query. |
startAt(fieldValues) |
Creates a QueryConstraint that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. |
terminate(firestore) |
Terminates the provided Firestore instance.After calling terminate() only the clearIndexedDbPersistence() function may be used. Any other function will throw a FirestoreError .To restart after termination, create a new instance of FirebaseFirestore with getFirestore().Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. If you have persistence enabled, the next time you start this instance, it will resume sending these writes to the server.Note: Under normal circumstances, calling terminate() is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with clearIndexedDbPersistence() to ensure that all local state is destroyed between test runs. |
updateDoc(reference, data) |
Updates fields in the document referred to by the specified DocumentReference . The update will fail if applied to a document that does not exist. |
updateDoc(reference, field, value, moreFieldsAndValues) |
Updates fields in the document referred to by the specified DocumentReference The update will fail if applied to a document that does not exist.Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects. |
useFirestoreEmulator(firestore, host, port) |
Modify this instance to communicate with the Cloud Firestore emulator.Note: This must be called before this instance has been used to do any operations. |
waitForPendingWrites(firestore) |
Waits until all currently pending writes for the active user have been acknowledged by the backend.The returned Promise resolves immediately if there are no outstanding writes. Otherwise, the Promise waits for all previously issued writes (including those written in a previous app session), but it does not wait for writes that were added after the function is called. If you want to wait for additional writes, call waitForPendingWrites() again.Any outstanding waitForPendingWrites() Promises are rejected during user changes. |
where(fieldPath, opStr, value) |
Creates a QueryConstraint that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. |
writeBatch(firestore) |
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.Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data. |