Skip to content

omit

transformers
Source Code | Documentation

Omit the specified fields from an item.

ts
  import { 
omit
} from 'feathers-utils/transformers';

Example

ts
import { transformData, transformResult, omit } from 'feathers-utils/transformers'

{
  before: {
    all: [transformData(omit('email'))],
  }
}

Hooks for transformers

HookDescription
transformData

Transforms each item in context.data using the provided transformer function. The transformer receives each item and can mutate it in place or return a new object. Commonly used with built-in transformers like lowercase, trim, or setNow.

transformQuery

Transforms context.params.query using the provided transformer function. The transformer receives the current query and can return a modified version. Useful for normalizing, sanitizing, or enriching queries before they hit the database.

transformResult

Transforms each item in context.result using the provided transformer function. The transformer receives each item and can mutate it in place or return a new object. Optionally operates on context.dispatch via the dispatch option.

Utilities for transformers

UtilityDescription
mutateData

Applies a transformer function to each item in context.data, updating it in place. If the transformer returns a new object, it replaces the original item. Correctly handles both single-item and array data, preserving the original shape.

mutateResult

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.

Type declaration

Show Type Declarations
ts
/**
 * Omit the specified fields from an item.
 *
 * @example
 * ```ts
 *
 *
 * {
 *   before: {
 *     all: [transformData(omit('email'))],
 *   }
 * }
 * ```
 *
 * @see https://utils.feathersjs.com/transformers/omit.html
 */
export declare const omit: (fieldNames: MaybeArray<string>) => TransformerFn
ArgumentTypeDescription
fieldNamesMaybeArray<string>

Released under the MIT License.