Skip to content

batching

Splits one logical operation into several service calls, or bundles several into one.

NameCategoryDescription
chunkFind
utils

Use for await to iterate over chunks (pages) of results from a find method.

This function is useful for processing large datasets in batches without loading everything into memory at once. It uses pagination to fetch results in chunks, yielding each page's data array.

createMany
utils

Creates all given items with a single create([...]) call.

If the service does not allow multi creating (its multi option, or an explicit multi option), the items are created with one call per item instead - so it works regardless of the service's multi configuration. A single item is always created with a single call.

iterateFind
utils

Use for await to iterate over the results of a find method.

This function is useful for iterating over large datasets without loading everything into memory at once. It uses pagination to fetch results in chunks, allowing you to process each item as it is retrieved.

patchBatch
utils

Batch patching utility that takes an array of items to be changed and returns an array of arguments to be called with the patch method.

This utility is useful when you need to patch multiple items with varying data in as few requests as possible.

patchMany
utils

Patches all items matching params with a single patch(null, ...) call.

If the service does not allow multi patching (its multi option, or an explicit multi option), the matching items are fetched with find and patched with one call per item instead - so it works regardless of the service's multi configuration.

The params only select which items are affected: the query is consumed by the find - which only collects the ids - and is not applied again for the per-item calls, except $select.

removeMany
utils

Removes all items matching params with a single remove(null, ...) call.

If the service does not allow multi removing (its multi option, or an explicit multi option), the matching items are fetched with find and removed with one call per item instead - so it works regardless of the service's multi configuration.

The params only select which items are affected: the query is consumed by the find - which only collects the ids - and is not applied again for the per-item calls, except $select.

See all tags for the full vocabulary.

Released under the MIT License.