콘솔로 이동

DocumentSnapshot

public class DocumentSnapshot extends Object
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.

Nested Class Summary

enum DocumentSnapshot.ServerTimestampBehavior Controls the return value for server timestamps that have not yet been set to their final value. 

Public Method Summary

boolean
contains(FieldPath fieldPath)
Returns whether or not the field exists in the document.
boolean
contains(String field)
Returns whether or not the field exists in the document.
boolean
boolean
<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
get(FieldPath fieldPath)
Returns the value at the field or null if the field or document doesn't exist.
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
get(FieldPath fieldPath, Class<T> valueType)
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)
Returns the value at the field, converted to a POJO, or null if the field or document 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<StringObject>
getData(DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the fields of the document as a Map or null if the document doesn't exist.
Map<StringObject>
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.
Date
getDate(String field, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
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
Long
getLong(String field)
Returns the value of the field as a long.
SnapshotMetadata
DocumentReference
getReference()
Gets the reference to the document.
String
getString(String field)
Returns the value of the field as a String.
Timestamp
getTimestamp(String field, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)
Returns the value of the field as a com.google.firebase.Timestamp.
Timestamp
getTimestamp(String field)
Returns the value of the field as a com.google.firebase.Timestamp.
int
<T> T
toObject(Class<T> valueType)
Returns the contents of the document converted to a POJO or null if the document doesn't exist.
<T> T
toObject(Class<T> valueType, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior)