Property

app

non-null firebase.firestore.app

The app associated with this Firestore service instance.

Methods

batch

batch() returns firebase.firestore.WriteBatch

Creates a write batch, used for performing multiple writes as a single atomic operation.

Returns

non-null firebase.firestore.WriteBatch A WriteBatch that can be used to atomically execute multiple writes.

collection

collection(collectionPath) returns firebase.firestore.CollectionReference

Gets a CollectionReference instance that refers to the collection at the specified path.

Parameter

collectionPath

string

A slash-separated path to a collection.

Returns

non-null firebase.firestore.CollectionReference The CollectionReference instance.

disableNetwork

disableNetwork() returns Promise containing void

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.

Returns

non-null Promise containing void A promise that is resolved once the network has been disabled.

doc

doc(documentPath) returns firebase.firestore.DocumentReference

Gets a DocumentReference instance that refers to the document at the specified path.

Parameter

documentPath

string

A slash-separated path to a document.

Returns

non-null firebase.firestore.DocumentReference The DocumentReference instance.

enableNetwork

enableNetwork() returns Promise containing void

Re-enables use of the network for this Firestore instance after a prior call to disableNetwork().

Returns

non-null Promise containing void A promise that is resolved once the network has been enabled.

enablePersistence

enablePersistence() returns Promise containing void

Attempts to enable persistent storage, if possible.

Must be called before any other methods (other than settings()).

If this fails, enablePersistence() 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.
Returns

non-null Promise containing void A promise that represents successfully enabling persistent storage.

runTransaction

runTransaction(updateFunction) returns Promise

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.

Parameter

updateFunction

function(non-null firebase.firestore.Transaction)

The function to execute within the transaction context.

Returns

non-null Promise If the transaction completed successfully or was explicitly aborted (the updateFunction returned a failed promise), the promise returned by the updateFunction is returned here. Else, if the transaction failed, a rejected promise with the corresponding failure error will be returned.

setLogLevel

setLogLevel(logLevel)

Sets the verbosity of Cloud Firestore logs (debug, error, or silent).

Parameter

logLevel

string

The verbosity you set for activity and error logging. Can be any of the following values:

  • debug for the most verbose logging level, primarily for dubugging.
  • error to log errors only.
  • silent to turn off logging.

settings

settings(settings)

Specifies custom settings to be used to configure the Firestore instance. Must be set before invoking any other methods.

Parameter

settings

firebase.firestore.Settings

The settings for your Cloud Firestore instance.

Value must not be null.

Abstract type

DocumentData

inner

object

An object containing all the data in a document.