Go to console

The Cloud Firestore service interface.

Do not call this constructor directly. Instead, use firebase.firestore().

Index

Constructors

Private constructor

Properties

app

app: App

The app associated with this Firestore service instance.

Methods

batch

  • batch(): WriteBatch
  • 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 of FieldValue.serverTimestamp(), FieldValue.arrayUnion(), FieldValue.arrayRemove(), or FieldValue.increment() inside a WriteBatch counts as an additional write.

    Returns WriteBatch

    A WriteBatch that can be used to atomically execute multiple writes.

clearPersistence

  • clearPersistence(): Promise<void>
  • 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 shutdown or when the app is first initialized). On startup, this method must be called before other methods (other than settings()). If the firestore instance is still running, the promise will be rejected with the error code of failed-precondition.

    Note: clearPersistence() is primarily intended to help write reliable tests that use Firestore. It uses the most efficient mechanism possible 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 cache data in between user sessions we strongly recommend not to enable persistence in the first place.

    Returns Promise<void>

    A promise that is resolved once the persistent storage has been cleared. Otherwise, the promise is rejected with an error.

collection

  • collection(collectionPath: string): CollectionReference
  • Gets a CollectionReference instance that refers to the collection at the specified path.

    Parameters

    • collectionPath: string

      A slash-separated path to a collection.

    Returns CollectionReference

    The CollectionReference instance.

collectionGroup

  • collectionGroup(collectionId: string): Query