voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
28 lines (16 loc) • 952 B
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@firebase/firestore](./firestore.md) > [/](./firestore_.md) > [setDoc](./firestore_.setdoc.md)
## setDoc() function
Writes to the document referred to by this `DocumentReference`<!-- -->. If the document does not yet exist, it will be created.
<b>Signature:</b>
```typescript
export declare function setDoc<T>(reference: DocumentReference<T>, data: T): Promise<void>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| reference | [DocumentReference](./firestore_.documentreference.md)<!-- --><T> | A reference to the document to write. |
| data | T | A map of the fields and values for the document. |
<b>Returns:</b>
Promise<void>
A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).