> For the complete documentation index, see [llms.txt](https://koboo.gitbook.io/en2do/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://koboo.gitbook.io/en2do/usage/updatebatch.md).

# UpdateBatch

Updating fields of documents.

To make it easier to work with individual fields, the native MongoDB driver has the `updateMany` method, which can be used to filter and then update documents.

This is provided in en2do via the `updateFieldsBy` method operator or via the predefined `updateAllFields(UpdateBatch updateBatch)` method.

*Example of using `UpdateBatch`:*

```java
// Remove the field "postalCode"
boolean success = repository.updateAllFields(UpdateBatch.of(FieldUpdate.remove("postalCode")));

// Rename the field "balance" to "balanceRenamed"
boolean success = repository.updateAllFields(UpdateBatch.of(FieldUpdate.rename("balance", "balanceRenamed"));

// Hard-Set the value of the field "postalCode" to 987654321
boolean success = repository.updateAllFields(UpdateBatch.of(FieldUpdate.set("postalCode", 987654321)));
```

To optimize performance in this respect, several `FieldUpdate` can be combined in one call.

*Example of multiple `FieldUpdate` in one call:*

```java
boolean success = repository.updateAllFields(UpdateBatch.of(
                FieldUpdate.remove("postalCode"),
                FieldUpdate.rename("balance", "balanceRenamed"),
                FieldUpdate.set("postalCode", 987654321)
        ));

```
