Globals

Abstract types

DocumentData  Object with any type properties

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

documentSnapshotCallback(snapshot)

onSnapshot() callback that receives a DocumentSnapshot.

Parameter

Name Type Optional Description

snapshot

DocumentSnapshot

 

A document snapshot.

errorCallback(err)

onSnapshot() callback that receives an error.

Parameter

Name Type Optional Description

err

Error

 

An error from a listen.

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.

Example

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 });
});

Property

Name Type Optional Description

lastUpdateTime

string

 

The update time to enforce (specified as an ISO 8601 string).

querySnapshotCallback(snapshot)

onSnapshot() callback that receives a QuerySnapshot.

Parameter

Name Type Optional 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.

Property

Name Type Optional Description

fieldMask

Array of (string or 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 }.

Properties

Name Type Optional 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 of (string or 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 with any type properties

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.