Go to console

The Cloud Firestore service interface.

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



Private constructor



app: App

The app associated with this Firestore service instance.



  • 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(): 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(collectionPath: string): CollectionReference
  • Gets a CollectionReference instance that refers to the collection at the specified path.


    • collectionPath: string

      A slash-separated path to a collection.

    Returns CollectionReference

    The CollectionReference instance.


  • collectionGroup(collectionId: string): Query
  • 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.


    • collectionId: string

      Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash.

    Returns Query

    The created Query.