Properties

read-only

createTime  unknown

The time the document was created.

Example

let query = firestore.collection('col');

query.get().forEach(snapshot => {
  console.log(`Document created at '${snapshot.createTime.toDate()}'`);
});
Inherited from
QueryDocumentSnapshot#createTime
read-only

exists  unknown

True if the document exists.

Example

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

documentRef.get().then((documentSnapshot) => {
  if (documentSnapshot.exists) {
    console.log(`Data: ${JSON.stringify(documentSnapshot.data())}`);
  }
});
Inherited from
DocumentSnapshot#exists
read-only

id  unknown

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

Example

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

documentRef.get().then((documentSnapshot) => {
  if (documentSnapshot.exists) {
    console.log(`Document found with name '${documentSnapshot.id}'`);
  }
});
Inherited from
DocumentSnapshot#id
read-only

readTime  unknown

The time this snapshot was read.

Example

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

documentRef.get().then(documentSnapshot => {
  let readTime = documentSnapshot.readTime;
  console.log(`Document read at '${readTime.toDate()}'`);
});
Inherited from
DocumentSnapshot#readTime
read-only

ref  unknown

A DocumentReference for the document stored in this snapshot.

Example

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

documentRef.get().then((documentSnapshot) => {
  if (documentSnapshot.exists) {
    console.log(`Found document at '${documentSnapshot.ref.path}'`);
  }
});
Inherited from
DocumentSnapshot#ref
read-only

updateTime  unknown

The time the document was last updated (at the time the snapshot was generated).

Example

let query = firestore.collection('col');

query.get().forEach(snapshot => {
  console.log(`Document updated at '${snapshot.updateTime.toDate()}'`);
});
Inherited from
QueryDocumentSnapshot#updateTime

Methods

data() → DocumentData

Retrieves all fields in the document as an object.

Example

let query = firestore.collection('col');

query.get().forEach(documentSnapshot => {
  let data = documentSnapshot.data();
  console.log(`Retrieved data: ${JSON.stringify(data)}`);
});
Inherited from
QueryDocumentSnapshot#data
Returns

An object containing all fields in the document.

get(field) → any type

Retrieves the field specified by field.

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

Parameter

Name Type Optional Description

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.

isEqual(other) → boolean

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

Parameter

Name Type Optional Description

other

 

 

The value to compare against.

Inherited from
DocumentSnapshot#isEqual
Returns

true if this DocumentSnapshot is equal to the provided value.