| Known Direct Subclasses |
A DocumentSnapshot contains data read from a document in your Cloud Firestore database.
The data can be extracted with the getData() or get(String) methods.
If the DocumentSnapshot points to a non-existing document, getData() and its
corresponding methods will return null. You can always explicitly check for a document's
existence by calling exists().
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.
| enum | DocumentSnapshot.ServerTimestampBehavior | Controls the return value for server timestamps that have not yet been set to their final value. | |
| boolean | |
| boolean | |
| boolean | |
| boolean |
exists()
|
| <T> T |
get(FieldPath fieldPath, Class<T> valueType, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the value at the field, converted to a POJO, or
null if the field or document
doesn't exist. |
| <T> T |
get(String field, Class<T> valueType, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the value at the field, converted to a POJO, or
null if the field or document
doesn't exist. |
| Object |
get(String field, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the value at the field or
null if the field doesn't exist. |
| Object | |
| Object |
get(FieldPath fieldPath, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the value at the field or
null if the field or document doesn't exist. |
| <T> T | |
| <T> T | |
| Object | |
| Blob | |
| Boolean | |
| Map<String, Object> |
getData(DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the fields of the document as a Map or
null if the document doesn't exist. |
| Map<String, Object> |
getData()
Returns the fields of the document as a Map or
null if the document doesn't exist. |
| Date | |
| Date |
getDate(String field, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the value of the field as a Date.
|
| DocumentReference | |
| Double | |
| GeoPoint | |
| String |
getId()
|
| Long | |
| SnapshotMetadata | |
| DocumentReference |
getReference()
Gets the reference to the document.
|
| String | |
| Timestamp |
getTimestamp(String field, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the value of the field as a
com.google.firebase.Timestamp. |
| Timestamp | |
| int |
hashCode()
|
| <T> T | |
| <T> T |
toObject(Class<T> valueType, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the contents of the document converted to a POJO or
null if the document
doesn't exist. |
| String |
toString()
|
Returns whether or not the field exists in the document. Returns false if the document does not exist.
| fieldPath | the path to the field. |
|---|
Returns whether or not the field exists in the document. Returns false if the document does not exist.
| field | the path to the field. |
|---|
Returns the value at the field, converted to a POJO, or null if the field or document
doesn't exist.
| fieldPath | The path to the field |
|---|---|
| valueType | The Java class to convert the field value to. |
| serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
null.
Returns the value at the field, converted to a POJO, or null if the field or document
doesn't exist.
| field | The path to the field |
|---|---|
| valueType | The Java class to convert the field value to. |
| serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
null.
Returns the value at the field or null if the field doesn't exist.
| field | The path to the field |
|---|---|
| serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
null.
Returns the value at the field or null if the field or document doesn't exist.
| fieldPath | The path to the field |
|---|
null.
Returns the value at the field or null if the field or document doesn't exist.
| fieldPath | The path to the field |
|---|---|
| serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
null.
Returns the value at the field, converted to a POJO, or null if the field or document
doesn't exist.
| fieldPath | The path to the field |
|---|---|
| valueType | The Java class to convert the field value to. |
null.
Returns the value at the field, converted to a POJO, or null if the field or document
doesn't exist.
| field | The path to the field |
|---|---|
| valueType | The Java class to convert the field value to. |
null.
Returns the value at the field or null if the field doesn't exist.
| field | The path to the field |
|---|
null.
Returns the value of the field as a Blob.
| field | The path to the field. |
|---|
| RuntimeException | if the value is not a Blob. |
|---|
Returns the value of the field as a boolean. If the value is not a boolean this will throw a runtime exception.
| field | The path to the field. |
|---|
Returns the fields of the document as a Map or null if the document doesn't exist.
Field values will be converted to their native Java representation.
| serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
|---|
null if the document doesn't exist.
Returns the fields of the document as a Map or null if the document doesn't exist.
Field values will be converted to their native Java representation.
null if the document doesn't exist.
Returns the value of the field as a Date.
| field | The path to the field. |
|---|
| RuntimeException | if the value is not a Date. |
|---|
Returns the value of the field as a Date.
| field | The path to the field. |
|---|---|
| serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
| RuntimeException | if the value is not a Date. |
|---|
Returns the value of the field as a DocumentReference.
| field | The path to the field. |
|---|
| RuntimeException | if the value is not a DocumentReference. |
|---|
Returns the value of the field as a double.
| field | The path to the field. |
|---|
| RuntimeException | if the value is not a number. |
|---|
Returns the value of the field as a GeoPoint.
| field | The path to the field. |
|---|
| RuntimeException | if the value is not a GeoPoint. |
|---|
Returns the value of the field as a long.
| field | The path to the field. |
|---|
| RuntimeException | if the value is not a number. |
|---|
Gets the reference to the document.
Returns the value of the field as a String.
| field | The path to the field. |
|---|
| RuntimeException | if the value is not a String. |
|---|
Returns the value of the field as a com.google.firebase.Timestamp.
| field | The path to the field. |
|---|---|
| serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
| RuntimeException | if the value is not a timestamp field. |
|---|
Returns the value of the field as a com.google.firebase.Timestamp.
| field | The path to the field. |
|---|
| RuntimeException | if this is not a timestamp field. |
|---|
Returns the contents of the document converted to a POJO or null if the document
doesn't exist.
| valueType | The Java class to create |
|---|
null if the document
doesn't exist.
Returns the contents of the document converted to a POJO or null if the document
doesn't exist.
| valueType | The Java class to create |
|---|---|
| serverTimestampBehavior | Configures the behavior for server timestamps that have not yet been set to their final value. |
null if the document
doesn't exist.