voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
31 lines (18 loc) • 1.46 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) > [setDoc](./firestore_lite.setdoc_1.md)
## setDoc() function
Writes to the document referred to by the specified `DocumentReference`<!-- -->. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`<!-- -->, the provided data can be merged into an existing document.
The result of this write will only be reflected in document reads that occur after the returned Promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK.
<b>Signature:</b>
```typescript
export declare function setDoc<T>(reference: DocumentReference<T>, data: Partial<T>, options: SetOptions): Promise<void>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| reference | [DocumentReference](./firestore_lite.documentreference.md)<!-- --><T> | A reference to the document to write. |
| data | Partial<T> | A map of the fields and values for the document. |
| options | [SetOptions](./firestore_lite.setoptions.md) | An object to configure the set behavior. |
<b>Returns:</b>
Promise<void>
A Promise resolved once the data has been successfully written to the backend.