Idle timeout used to detect Watch streams that stall (see, b/156308554). Under normal load, the Watch backend will send a TARGET_CHANGE message roughly every 30 seconds. As discussed with the backend team, we reset the Watch stream if we do not receive any message within 120 seconds.



Returns the list of retryable error codes specified in the service configuration.


Returns the backoff setting from the service configuration.


Sets or disables the log function for all active Firestore instances.

Name Type Description

A log function that takes a message (such as console.log) or null to turn off logging.

Type Definitions

DocumentData :Object.<string, *>

Document data (e.g. for use with set()) consisting of fields mapped to values.


onSnapshot() callback that receives a DocumentSnapshot.

Name Type Description
snapshot DocumentSnapshot

A document snapshot.


onSnapshot() callback that receives an error.

Name Type Description
err Error

An error from a listen.

FirestoreDataConverter :Object

Converter used by withConverter() to transform user objects of type T into Firestore data.

Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.

Name Type Description
toFirestore function

Called by the Firestore SDK to convert a custom model object of type T into a plain Javascript object (suitable for writing directly to the Firestore database).

fromFirestore function

Called by the Firestore SDK to convert Firestore data into an object of type T.

class Post {
  constructor(readonly title: string, readonly author: string) {}

  toString(): string {
    return this.title + ', by ' +;

const postConverter = {
  toFirestore(post: Post): FirebaseFirestore.DocumentData {
    return {title: post.title, author:};
    data: FirebaseFirestore.QueryDocumentSnapshot
  ): Post {
    const data =;
    return new Post(data.title,;

const postSnap = await Firestore()
const post =;
if (post !== undefined) {
  post.title; // string
  post.toString(); // Should be defined
  post.someNonExistentProperty; // TS error

Precondition :Object

An options object that configures conditional behavior of update() and delete() calls in DocumentReference, WriteBatch, and Transaction. Using Preconditions, these calls can be restricted to only apply to documents that match the specified conditions.

Name Type Description
lastUpdateTime Timestamp

The update time to enforce. If set, enforces that the document was last updated at lastUpdateTime. Fails the operation if the document was last updated at a different time.

const documentRef = firestore.doc('coll/doc');

documentRef.get().then(snapshot => {
  const updateTime = snapshot.updateTime;

  console.log(`Deleting document at update time: ${updateTime.toDate()}`);
  return documentRef.delete({ lastUpdateTime: updateTime });


onSnapshot() callback that receives a QuerySnapshot.

Name Type Description
snapshot QuerySnapshot

A query snapshot.

ReadOptions :Object

An options object that can be used to configure the behavior of getAll() calls. By providing a fieldMask, these calls can be configured to only return a subset of fields.

Name Type Description
fieldMask Array.<(string|FieldPath)>

Specifies the set of fields to return and reduces the amount of data transmitted by the backend. Adding a field mask does not filter results. Documents do not need to contain values for all the fields in the mask to be part of the result set.

SetOptions :Object

An options object that configures the behavior of set() calls in DocumentReference, WriteBatch, and Transaction. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions object with { merge : true }.

Name Type Description
merge boolean

Changes the behavior of a set() call to only replace the values specified in its data argument. Fields omitted from the set() call remain untouched.

mergeFields Array.<(string|FieldPath)>

Changes the behavior of set() calls to only replace the specified field paths. Any field path that is not specified is ignored and remains untouched. It is an error to pass a SetOptions object to a set() call that is missing a value for any of the fields specified here.

UpdateData :Object.<string, *>

Update data (for use with update) that contains paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document.