voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
27 lines (15 loc) • 1.27 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@firebase/firestore](./firestore.md) > [lite](./firestore_lite.md) > [DocumentReference](./firestore_lite.documentreference.md) > [withConverter](./firestore_lite.documentreference.withconverter.md)
## DocumentReference.withConverter() method
Applies a custom data converter to this `DocumentReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.setdoc.md)<!-- -->, [getDoc()](./firestore_lite.getdoc.md)<!-- -->, etc. with the returned `DocumentReference` instance, the provided converter will convert between Firestore data and your custom type `U`<!-- -->.
<b>Signature:</b>
```typescript
withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| converter | [FirestoreDataConverter](./firestore_lite.firestoredataconverter.md)<!-- --><U> | Converts objects to and from Firestore. |
<b>Returns:</b>
[DocumentReference](./firestore_lite.documentreference.md)<!-- --><U>
A `DocumentReference<U>` that uses the provided converter.