mutateResult
utils
Source Code | DocumentationSee also: hooks/transformResult transformers
Applies a transformer function to each item in context.result (and optionally context.dispatch). Handles paginated results, single items, and arrays transparently. Use the dispatch option to control whether result, dispatch, or both are transformed.
ts
import { mutateResult } from 'feathers-utils/utils';Example
ts
import { mutateResult } from 'feathers-utils/utils'
await mutateResult(context, (item) => { delete item.password })Type declaration
Show Type Declarations
ts
export type MutateResultOptions = {
next?: NextFunction
transform?: (items: any[]) => any[]
dispatch?: DispatchOption
}
/**
* Applies a transformer function to each item in `context.result` (and optionally `context.dispatch`).
* Handles paginated results, single items, and arrays transparently.
* Use the `dispatch` option to control whether result, dispatch, or both are transformed.
*
* @example
* ```ts
*
*
* await mutateResult(context, (item) => { delete item.password })
* ```
*
* @see https://utils.feathersjs.com/utils/mutate-result.html
*/
export declare function mutateResult<H extends HookContext = HookContext>(
context: H,
transformer: TransformerFn<any, H>,
options?: MutateResultOptions,
): Promise<H>| Argument | Type | Description |
|---|---|---|
| context | H | |
| transformer | TransformerFn<any, H> | |
| options | MutateResultOptions |
