A QueryDocumentSnapshot contains data read from a document in your
Firestore database as part of a query. The document is guaranteed to exist
and its data can be extracted with .data() or .get(<field>) to get a
specific field.
A QueryDocumentSnapshot offers the same API surface as a
DocumentSnapshot. Since query results contain only existing documents, the
exists property will always be true and data() will never return
'undefined'.
Retrieves all fields in the document as an Object.
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).
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/js/v8/firebase).\n- [firestore](/docs/reference/js/v8/firebase.firestore).\n- QueryDocumentSnapshot\n\\\u003c T \\\u003e \nA `QueryDocumentSnapshot` contains data read from a document in your\nFirestore database as part of a query. The document is guaranteed to exist\nand its data can be extracted with `.data()` or `.get(\u003cfield\u003e)` to get a\nspecific field.\n\nA `QueryDocumentSnapshot` offers the same API surface as a\n`DocumentSnapshot`. Since query results contain only existing documents, the\n`exists` property will always be true and `data()` will never return\n'undefined'.\n\nType parameters\n\n-\n\n T\n\nIndex\n\nConstructors\n\n- [constructor](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot#constructor)\n\nProperties\n\n- [exists](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot#exists)\n- [id](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot#id)\n- [metadata](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot#metadata)\n- [ref](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot#ref)\n\nMethods\n\n- [data](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot#data)\n- [get](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot#get)\n- [isEqual](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot#isequal)\n\nConstructors\n\nPrivate constructor\n\n- new QueryDocumentSnapshot ( ) : [QueryDocumentSnapshot](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot)\n-\n | Overrides [DocumentSnapshot](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot).[constructor](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot#constructor)\n\n Returns [QueryDocumentSnapshot](/docs/reference/js/v8/firebase.firestore.QueryDocumentSnapshot)\n\nProperties\n\nexists \nexists: boolean\nInherited from [DocumentSnapshot](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot).[exists](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot#exists) \nProperty of the `DocumentSnapshot` that signals whether or not the data\nexists. True if the document exists.\n\nid \nid: string\nInherited from [DocumentSnapshot](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot).[id](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot#id) \nProperty of the `DocumentSnapshot` that provides the document's ID.\n\nmetadata \nmetadata: [SnapshotMetadata](/docs/reference/js/v8/firebase.firestore.SnapshotMetadata)\nInherited from [DocumentSnapshot](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot).[metadata](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot#metadata) \nMetadata about the `DocumentSnapshot`, including information about its\nsource and local modifications.\n\nref \nref: [DocumentReference](/docs/reference/js/v8/firebase.firestore.DocumentReference)\\\u003cT\\\u003e\nInherited from [DocumentSnapshot](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot).[ref](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot#ref) \nThe `DocumentReference` for the document included in the `DocumentSnapshot`.\n\nMethods\n\ndata\n\n- data ( options ? : [SnapshotOptions](/docs/reference/js/v8/firebase.firestore.SnapshotOptions) ) : T\n-\n Overrides [DocumentSnapshot](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot).[data](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot#data) \n Retrieves all fields in the document as an Object.\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 override\n :\n\n Parameters\n -\n\n Optional options: [SnapshotOptions](/docs/reference/js/v8/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\n\n An Object containing all fields in the document.\n\nget\n\n- get ( fieldPath : string \\| [FieldPath](/docs/reference/js/v8/firebase.firestore.FieldPath) , options ? : [SnapshotOptions](/docs/reference/js/v8/firebase.firestore.SnapshotOptions) ) : any\n-\n Inherited from [DocumentSnapshot](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot).[get](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot#get) \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/js/v8/firebase.firestore.FieldPath) \n The path (e.g. 'foo' or 'foo.bar') to a specific field.\n -\n\n Optional options: [SnapshotOptions](/docs/reference/js/v8/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/js/v8/firebase.firestore.DocumentSnapshot) \\\u003c T \\\u003e ) : boolean\n-\n Inherited from [DocumentSnapshot](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot).[isEqual](/docs/reference/js/v8/firebase.firestore.DocumentSnapshot#isequal) \n Returns true if this `DocumentSnapshot` is equal to the provided one.\n\n Parameters\n -\n\n other: [DocumentSnapshot](/docs/reference/js/v8/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
QueryDocumentSnapshot
contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with.data()
or.get(<field>)
to get a specific field.A
QueryDocumentSnapshot
offers the same API surface as aDocumentSnapshot
. Since query results contain only existing documents, theexists
property will always be true anddata()
will never return 'undefined'.