The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/firestore > / > DocumentSnapshot > data

DocumentSnapshot.data() method

Retrieves all fields in the document as an Object. Returns undefined if the document doesn't exist.

By default, FieldValue.serverTimestamp() values that have not yet been set to their final value will be returned as null. You can override this by passing an options object.

Signature:

data(options?: SnapshotOptions): T | undefined;

Parameters

Parameter Type Description
options SnapshotOptions An options object to configure how data is retrieved from the snapshot (for example the desired behavior for server timestamps that have not yet been set to their final value).

Returns:

T | undefined

An Object containing all fields in the document or undefined if the document doesn't exist.