A DocumentSnapshot contains data read from a document in your Firestore
database. The data can be extracted with .data() or .get(<field>) to
get a specific field.
For a DocumentSnapshot that points to a non-existing document, any data
access will return 'undefined'. You can use the exists property to
explicitly verify a document's existence.
Retrieves all fields in the document as an Object. Returns 'undefined' if
the document doesn't exist.
By default, FieldValue.serverTimestamp() values that have not yet been
set to their final value will be returned as null. You can override
this by passing an options object.
An options object to configure how data is retrieved from
the snapshot (e.g. the desired behavior for server timestamps that have
not yet been set to their final value).
Returns T | undefined
An Object containing all fields in the document or 'undefined' if
the document doesn't exist.
Retrieves the field specified by fieldPath. Returns undefined if the
document or field doesn't exist.
By default, a FieldValue.serverTimestamp() that has not yet been set to
its final value will be returned as null. You can override this by
passing an options object.
An options object to configure how the field is retrieved
from the snapshot (e.g. the desired behavior for server timestamps that have
not yet been set to their final value).
Returns any
The data at the specified field location or undefined if no such
field exists in the document.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-07-27 UTC."],[],[],null,["- [firebase](/docs/reference/node/firebase).\n- [firestore](/docs/reference/node/firebase.firestore).\n- DocumentSnapshot\n\\\u003c T \\\u003e \nA `DocumentSnapshot` contains data read from a document in your Firestore\ndatabase. The data can be extracted with `.data()` or `.get(\u003cfield\u003e)` to\nget a specific field.\n\nFor a `DocumentSnapshot` that points to a non-existing document, any data\naccess will return 'undefined'. You can use the `exists` property to\nexplicitly verify a document's existence.\n\nType parameters\n\n-\n\n T\n\nIndex\n\nConstructors\n\n- [constructor](/docs/reference/node/firebase.firestore.DocumentSnapshot#constructor)\n\nProperties\n\n- [exists](/docs/reference/node/firebase.firestore.DocumentSnapshot#exists)\n- [id](/docs/reference/node/firebase.firestore.DocumentSnapshot#id)\n- [metadata](/docs/reference/node/firebase.firestore.DocumentSnapshot#metadata)\n- [ref](/docs/reference/node/firebase.firestore.DocumentSnapshot#ref)\n\nMethods\n\n- [data](/docs/reference/node/firebase.firestore.DocumentSnapshot#data)\n- [get](/docs/reference/node/firebase.firestore.DocumentSnapshot#get)\n- [isEqual](/docs/reference/node/firebase.firestore.DocumentSnapshot#isequal)\n\nConstructors\n\nProtected constructor\n\n- new DocumentSnapshot ( ) : [DocumentSnapshot](/docs/reference/node/firebase.firestore.DocumentSnapshot)\n-\n\n Returns [DocumentSnapshot](/docs/reference/node/firebase.firestore.DocumentSnapshot)\n\nProperties\n\nexists \nexists: boolean \nProperty of the `DocumentSnapshot` that signals whether or not the data\nexists. True if the document exists.\n\nid \nid: string \nProperty of the `DocumentSnapshot` that provides the document's ID.\n\nmetadata \nmetadata: [SnapshotMetadata](/docs/reference/node/firebase.firestore.SnapshotMetadata) \nMetadata about the `DocumentSnapshot`, including information about its\nsource and local modifications.\n\nref \nref: [DocumentReference](/docs/reference/node/firebase.firestore.DocumentReference)\\\u003cT\\\u003e \nThe `DocumentReference` for the document included in the `DocumentSnapshot`.\n\nMethods\n\ndata\n\n- data ( options ? : [SnapshotOptions](/docs/reference/node/firebase.firestore.SnapshotOptions) ) : T \\| undefined\n- Retrieves all fields in the document as an Object. Returns 'undefined' if\n the document doesn't exist.\n\n By default, `FieldValue.serverTimestamp()` values that have not yet been\n set to their final value will be returned as `null`. You can override\n this by passing an options object.\n\n Parameters\n -\n\n Optional options: [SnapshotOptions](/docs/reference/node/firebase.firestore.SnapshotOptions) \n An options object to configure how data is retrieved from\n the snapshot (e.g. the desired behavior for server timestamps that have\n not yet been set to their final value).\n\n Returns T \\| undefined\n\n An Object containing all fields in the document or 'undefined' if\n the document doesn't exist.\n\nget\n\n- get ( fieldPath : string \\| [FieldPath](/docs/reference/node/firebase.firestore.FieldPath) , options ? : [SnapshotOptions](/docs/reference/node/firebase.firestore.SnapshotOptions) ) : any\n- Retrieves the field specified by `fieldPath`. Returns `undefined` if the\n document or field doesn't exist.\n\n By default, a `FieldValue.serverTimestamp()` that has not yet been set to\n its final value will be returned as `null`. You can override this by\n passing an options object.\n\n Parameters\n -\n\n fieldPath: string \\| [FieldPath](/docs/reference/node/firebase.firestore.FieldPath) \n The path (e.g. 'foo' or 'foo.bar') to a specific field.\n -\n\n Optional options: [SnapshotOptions](/docs/reference/node/firebase.firestore.SnapshotOptions) \n An options object to configure how the field is retrieved\n from the snapshot (e.g. the desired behavior for server timestamps that have\n not yet been set to their final value).\n\n Returns any\n\n The data at the specified field location or undefined if no such\n field exists in the document.\n\nisEqual\n\n- isEqual ( other : [DocumentSnapshot](/docs/reference/node/firebase.firestore.DocumentSnapshot) \\\u003c T \\\u003e ) : boolean\n- Returns true if this `DocumentSnapshot` is equal to the provided one.\n\n Parameters\n -\n\n other: [DocumentSnapshot](/docs/reference/node/firebase.firestore.DocumentSnapshot)\\\u003cT\\\u003e \n The `DocumentSnapshot` to compare against.\n\n Returns boolean\n\ntrue if this `DocumentSnapshot` is equal to the provided one."]]
A
DocumentSnapshot
contains data read from a document in your Firestore database. The data can be extracted with.data()
or.get(<field>)
to get a specific field.For a
DocumentSnapshot
that points to a non-existing document, any data access will return 'undefined'. You can use theexists
property to explicitly verify a document's existence.