voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
32 lines (19 loc) • 1.34 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@firebase/firestore](./firestore.md) > [/](./firestore_.md) > [WriteBatch](./firestore_.writebatch.md) > [update](./firestore_.writebatch.update_1.md)
## WriteBatch.update() method
Updates fields in the document referred to by this [DocumentReference](./firestore_.documentreference.md)<!-- -->. The update will fail if applied to a document that does not exist.
Nested fields can be update by providing dot-separated field path strings or by providing `FieldPath` objects.
<b>Signature:</b>
```typescript
update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): WriteBatch;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| documentRef | [DocumentReference](./firestore_.documentreference.md)<!-- --><unknown> | A reference to the document to be updated. |
| field | string \| [FieldPath](./firestore_.fieldpath.md) | The first field to update. |
| value | unknown | The first value. |
| moreFieldsAndValues | unknown\[\] | Additional key value pairs. |
<b>Returns:</b>
[WriteBatch](./firestore_.writebatch.md)
This `WriteBatch` instance. Used for chaining method calls.