Properties

createTime

read-only

unknown

The time the document was created. Undefined for documents that don't exist.

Inherited from
DocumentSnapshot#createTime

Example

let documentRef = firestore.doc('col/doc');

documentRef.get().then((documentSnapshot) => {
  if (documentSnapshot.exists) {
    console.log(`Document created at '${documentSnapshot.createTime}'`);
  }
});

exists

read-only

unknown

True if the document exists.

Inherited from
DocumentSnapshot#exists

Example

let documentRef = firestore.doc('col/doc');

documentRef.get().then((documentSnapshot) => {
  if (documentSnapshot.exists) {
    console.log(`Data: ${JSON.stringify(documentSnapshot.data())}`);
  }
});

id

read-only

unknown

The ID of the document for which this DocumentSnapshot contains data.

Inherited from
DocumentSnapshot#id

Example

let documentRef = firestore.doc('col/doc');

documentRef.get().then((documentSnapshot) => {
  if (documentSnapshot.exists) {
    console.log(`Document found with name '${documentSnapshot.id}'`);
  }
});

readTime

read-only

unknown

The time this snapshot was read.

Inherited from
DocumentSnapshot#readTime

Example

let documentRef = firestore.doc('col/doc');

documentRef.get().then((documentSnapshot) => {
  console.log(`Document read at '${documentSnapshot.readTime}'`);
});

ref

read-only

unknown

A DocumentReference for the document stored in this snapshot.

Inherited from
DocumentSnapshot#ref

Example

let documentRef = firestore.doc('col/doc');

documentRef.get().then((documentSnapshot) => {
  if (documentSnapshot.exists) {
    console.log(`Found document at '${documentSnapshot.ref.path}'`);
  }
});

updateTime

read-only

unknown

The time the document was last updated (at the time the snapshot was generated). Undefined for documents that don't exist.

Inherited from
DocumentSnapshot#updateTime

Example

let documentRef = firestore.doc('col/doc');

documentRef.get().then((documentSnapshot) => {
  if (documentSnapshot.exists) {
    console.log(`Document updated at '${documentSnapshot.updateTime}'`);
  }
});

Methods

data

data() returns (DocumentData or undefined)

Retrieves all fields in the document as an object. Returns 'undefined' if the document doesn't exist.

Inherited from
DocumentSnapshot#data
Returns

An object containing all fields in the document or 'undefined' if the document doesn't exist.

Example

let documentRef = firestore.doc('col/doc');

documentRef.get().then(documentSnapshot => {
  let data = documentSnapshot.data();
  console.log(`Retrieved data: ${JSON.stringify(data)}`);
});

get

get(field) returns any type

Retrieves the field specified by field.

Parameter

field

The field path (e.g. 'foo' or 'foo.bar') to a specific field.

Inherited from
DocumentSnapshot#get
Returns

The data at the specified field location or undefined if no such field exists.

Example

let documentRef = firestore.doc('col/doc');

documentRef.set({ a: { b: 'c' }}).then(() => {
  return documentRef.get();
}).then(documentSnapshot => {
  let field = documentSnapshot.get('a.b');
  console.log(`Retrieved field value: ${field}`);
});

isEqual

isEqual(other) returns boolean

Returns true if the document's data and path in this DocumentSnapshot is equal to the provided value.

Parameter

other

The value to compare against.

Inherited from
DocumentSnapshot#isEqual
Returns

true if this DocumentSnapshot is equal to the provided value.