<!-- 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_1.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). Used with ,  and  with `merge:true` or `mergeFields`<!-- -->.

<b>Signature:</b>

```typescript
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  modelObject | Partial&lt;T&gt; |  |
|  options | [SetOptions](./firestore_.setoptions.md) |  |

<b>Returns:</b>

[DocumentData](./firestore_.documentdata.md)

