Class Overview
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 using the getData() or
get() methods.
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: 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.
Summary
Public Methods |
Map<String, Object>
|
getData()
Returns the fields of the document as a Map.
|
<T>
T
|
toObject(Class<T> valueType)
Returns the contents of the document converted to a POJO.
|
[Expand]
Inherited Methods |
From class
com.google.firebase.firestore.DocumentSnapshot
boolean
|
contains(String field)
Returns whether or not the field exists in the document.
|
boolean
|
contains(FieldPath fieldPath)
Returns whether or not the field exists in the document.
|
boolean
|
equals(Object obj)
|
boolean
|
exists()
|
Object
|
get(FieldPath fieldPath)
Returns the value at the field or null if the field doesn't exist.
|
Object
|
get(String field)
Returns the value at the field or null if the field doesn't exist.
|
Blob
|
getBlob(String field)
Returns the value of the field as a Blob.
|
Boolean
|
getBoolean(String field)
Returns the value of the field as a boolean.
|
Map<String, Object>
|
getData()
Returns the fields of the document as a Map or null if the document doesn't exist.
|
Date
|
getDate(String field)
Returns the value of the field as a Date.
|
DocumentReference
|
getDocumentReference(String field)
Returns the value of the field as a DocumentReference.
|
Double
|
getDouble(String field)
Returns the value of the field as a double.
|
GeoPoint
|
getGeoPoint(String field)
Returns the value of the field as a GeoPoint.
|
String
|
getId()
|
Long
|
getLong(String field)
Returns the value of the field as a long.
|
SnapshotMetadata
|
getMetadata()
|
DocumentReference
|
getReference()
Gets the reference to the document.
|
String
|
getString(String field)
Returns the value of the field as a String.
|
int
|
hashCode()
|
<T>
T
|
toObject(Class<T> valueType)
Returns the contents of the document converted to a POJO or null if the document doesn't exist.
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public Methods
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 |
Map<String, Object> |
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 |
Class : The Java class to create |
Returns |
T |
The contents of the document in an object of type T
|