voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
29 lines (16 loc) • 1.18 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@firebase/firestore](./firestore.md) > [/](./firestore_.md) > [DocumentSnapshot](./firestore_.documentsnapshot.md) > [data](./firestore_.documentsnapshot.data.md)
## 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.
<b>Signature:</b>
```typescript
data(options?: SnapshotOptions): T | undefined;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| options | [SnapshotOptions](./firestore_.snapshotoptions.md) | 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). |
<b>Returns:</b>
T \| undefined
An `Object` containing all fields in the document or `undefined` if the document doesn't exist.