Skip to content

mutateResult

utils
Source Code | Documentation

See 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>
ArgumentTypeDescription
contextH
transformerTransformerFn<any, H>
optionsMutateResultOptions

Released under the MIT License.