A QueryDocumentSnapshot
contains data read from a document in your Cloud
Firestore database as part of a query. The document is guaranteed to exist and its data can
be extracted using the getData()
or the various get()
methods in DocumentSnapshot
(such as
get(String)
).
QueryDocumentSnapshot
offers the same API surface as
DocumentSnapshot
. Since query results contain only existing documents, the
exists()
method will always return true and getData()
will never be null
.
Subclassing Note: Cloud Firestore classes are not meant to be subclassed except for use in test mocks. Subclassing is not supported in production code and new SDK releases may break code that does so.
Public Method Summary
Map<String, Object> |
getData(DocumentSnapshot.ServerTimestampBehavior
serverTimestampBehavior)
Returns the fields of the document as a Map.
|
Map<String, Object> |
getData()
Returns the fields of the document as a Map.
|
<T> T | |
<T> T |
toObject(Class<T>
valueType,
DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the contents of the document converted to a POJO.
|
Inherited Method Summary
Public Methods
public Map<String, Object> getData (DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the fields of the document as a Map. Field values will be converted to their native Java representation.
Parameters
serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
---|
Returns
- The fields of the document as a Map or
null
if the document doesn't exist.
public Map<String, Object> getData ()
Returns the fields of the document as a Map. Field values will be converted to their native Java representation.
Returns
- The fields of the document as a Map.
public T toObject (Class<T> valueType)
Returns the contents of the document converted to a POJO.
Parameters
valueType | The Java class to create |
---|
Returns
- The contents of the document in an object of type T
public T toObject (Class<T> valueType, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the contents of the document converted to a POJO.
Parameters
valueType | The Java class to create |
---|---|
serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
Returns
- The contents of the document in an object of type T.