<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@firebase/firestore](./firestore.md) &gt; [/](./firestore_.md) &gt; [FirestoreDataConverter](./firestore_.firestoredataconverter.md) &gt; [toFirestore](./firestore_.firestoredataconverter.tofirestore.md)

## FirestoreDataConverter.toFirestore() method

Called by the Firestore SDK to convert a custom model object of type `T` into a plain JavaScript object (suitable for writing directly to the Firestore database). To use `set()` with `merge` and `mergeFields`<!-- -->, `toFirestore()` must be defined with `Partial<T>`<!-- -->.

<b>Signature:</b>

```typescript
toFirestore(modelObject: T): DocumentData;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  modelObject | T |  |

<b>Returns:</b>

[DocumentData](./firestore_.documentdata.md)

