# Class BaseBatch (2.27.0)

2.27.0 (latest) 2.26.0 2.23.0 2.22.0 2.21.0 2.20.2 2.19.0 2.18.0 2.17.2 2.16.1 2.15.0 2.14.0 2.13.1 2.12.0 2.11.1 2.10.1 2.9.1 2.8.0 2.7.3 2.6.1 2.5.3 2.4.0 2.3.4 2.2.0 2.1.3 2.0.2 1.9.2 1.8.1 1.7.0 1.6.2 1.5.0 1.4.0 1.3.0

    BaseBatch(client)

Accumulate write operations to be sent in a batch.

This has the same set of methods for write operations that
xref_DocumentReference does,
e.g. xref_create.

| ## Parameter ||
|---|---|
| **Name** | **Description** |
| `client` | `https://docs.cloud.google.com/python/docs/reference/firestore/latest/google.cloud.firestore_v1.client.Client` The client that created this batch. |

## Methods

### commit

    commit()

Sends all accumulated write operations to the server. The details of this
write depend on the implementing class.

### create

    create(
        reference: google.cloud.firestore_v1.base_document.BaseDocumentReference,
        document_data: dict[str, typing.Any],
    ) -> None

Add a "change" to this batch to create a document.

If the document given by `reference` already exists, then this
batch will fail when `commit`-ed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `reference` | `https://docs.cloud.google.com/python/docs/reference/firestore/latest/google.cloud.firestore_v1.document.DocumentReference` A document reference to be created in this batch. |
| `document_data` | `dict` Property names and values to use for creating a document. |

### delete

    delete(
        reference: google.cloud.firestore_v1.base_document.BaseDocumentReference,
        option: typing.Optional[google.cloud.firestore_v1._helpers.WriteOption] = None,
    ) -> None

Add a "change" to delete a document.

See
xref_delete
for more information on how `option` determines how the change is
applied.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `reference` | `https://docs.cloud.google.com/python/docs/reference/firestore/latest/google.cloud.firestore_v1.document.DocumentReference` A document reference that will be deleted in this batch. |
| `option` | `Optional[WriteOption]` A write option to make assertions / preconditions on the server state of the document before applying changes. |

### set

    set(
        reference: google.cloud.firestore_v1.base_document.BaseDocumentReference,
        document_data: dict,
        merge: typing.Union[bool, list] = False,
    ) -> None

Add a "change" to replace a document.

See
xref_set for
more information on how `option` determines how the change is
applied.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `reference` | `https://docs.cloud.google.com/python/docs/reference/firestore/latest/google.cloud.firestore_v1.document.DocumentReference` A document reference that will have values set in this batch. |
| `document_data` | `dict` Property names and values to use for replacing a document. |
| `merge` | `Optional[bool] or Optional[List` If True, apply merging instead of overwriting the state of the document. |

### update

    update(
        reference: google.cloud.firestore_v1.base_document.BaseDocumentReference,
        field_updates: dict[str, typing.Any],
        option: typing.Optional[google.cloud.firestore_v1._helpers.WriteOption] = None,
    ) -> None

Add a "change" to update a document.

See
xref_update
for more information on `field_updates` and `option`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `reference` | `https://docs.cloud.google.com/python/docs/reference/firestore/latest/google.cloud.firestore_v1.document.DocumentReference` A document reference that will be updated in this batch. |
| `field_updates` | `dict` Field names or paths to update and values to update with. |
| `option` | `Optional[WriteOption]` A write option to make assertions / preconditions on the server state of the document before applying changes. |