Skip to content

multi

Concerns the multi flag or the single-vs-many shape of data and results.

NameCategoryDescription
checkMulti
hooks

Checks if the multi option is enabled for the current method and throws a MethodNotAllowed error if multi operations are not permitted. Useful to guard against accidental bulk create, patch, or remove calls.

throwIfIsMulti
hooks

Throws a BadRequest error when the current operation is a multi operation (array data on create, or id === null on patch/remove). Useful to prevent bulk operations on services that should only handle single items.

getDataIsArray
utils

Normalizes context.data into an array for uniform processing. Returns { data, isArray } where data is always an array and isArray indicates whether the original value was already an array.

getResultIsArray
utils

Normalizes context.result (or context.dispatch) into an array for uniform processing. Handles paginated results by extracting the data array. Returns { result, isArray, key } where key indicates whether 'result' or 'dispatch' was used.

zipDataResult
utils

Pairs each item in context.data with its corresponding item in context.result by index. Handles both single-item and array data, normalizing them into an array of { data, result } pairs. Only works in after/around hooks for create, update, and patch methods.

isMulti
predicates

Checks if the current hook context represents a multi operation. Returns true for find, for create with array data, and for patch/remove with id === null. Returns false for get and update.

See all tags for the full vocabulary.

Released under the MIT License.