FirebaseFirestore Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
QueryDocumentSnapshot
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 the
data
property or by using subscript syntax to access a specific field.
A QueryDocumentSnapshot
offers the same API surface as a DocumentSnapshot
. As
deleted documents are not returned from queries, its exists
property will always be true and
data()
will never return nil
.
-
Retrieves all fields in the document as a Dictionary
.
Server-provided timestamps that have not yet been set to their final value will be returned as
NSNull
. You can use the data(with:)
method to configure this behavior.
Declaration
Swift
func data() -> [String : Any]
Return Value
A Dictionary
containing all fields in the document.
-
Retrieves all fields in the document as a Dictionary
.
Parameters
serverTimestampBehavior
|
Configures how server timestamps that have not yet been set to
their final value are returned from the snapshot.
|
Return Value
A Dictionary
containing all fields in the document.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-11 UTC.
[null,null,["Last updated 2025-03-11 UTC."],[],[],null,["# FirebaseFirestore Framework Reference\n\nQueryDocumentSnapshot\n=====================\n\n class QueryDocumentSnapshot : ../Classes/DocumentSnapshot.html\n\nA `QueryDocumentSnapshot` contains data read from a document in your Firestore database as\npart of a query. The document is guaranteed to exist and its data can be extracted with the\n`data` property or by using subscript syntax to access a specific field.\n\nA `QueryDocumentSnapshot` offers the same API surface as a [DocumentSnapshot](../Classes/DocumentSnapshot.html). As\ndeleted documents are not returned from queries, its `exists` property will always be true and\n`data()` will never return `nil`.\n- `\n ``\n ``\n `\n\n ### [data()](#/c:objc(cs)FIRQueryDocumentSnapshot(im)data)\n\n `\n ` \n Retrieves all fields in the document as a `Dictionary`.\n\n Server-provided timestamps that have not yet been set to their final value will be returned as\n `NSNull`. You can use the [data(with:)](../Classes/QueryDocumentSnapshot.html#/c:objc(cs)FIRQueryDocumentSnapshot(im)dataWithServerTimestampBehavior:) method to configure this behavior. \n\n #### Declaration\n\n Swift \n\n func data() -\u003e [String : Any]\n\n #### Return Value\n\n A `Dictionary` containing all fields in the document.\n- `\n ``\n ``\n `\n\n ### [data(with:)](#/c:objc(cs)FIRQueryDocumentSnapshot(im)dataWithServerTimestampBehavior:)\n\n `\n ` \n Retrieves all fields in the document as a `Dictionary`. \n\n #### Declaration\n\n Swift \n\n func data(with serverTimestampBehavior: ../Enums/ServerTimestampBehavior.html) -\u003e [String : Any]\n\n #### Parameters\n\n |---------------------------------|------------------------------------------------------------------------------------------------------------------|\n | ` `*serverTimestampBehavior*` ` | Configures how server timestamps that have not yet been set to their final value are returned from the snapshot. |\n\n #### Return Value\n\n A `Dictionary` containing all fields in the document."]]