Skip to content

resolveResult

resolvers
Source Code | Documentation

Resolves and transforms context.result using a map of resolver functions. Each property in the resolver object receives the current value and can return a transformed value. Runs after next() in the hook pipeline.

ts
  import {  } from 'feathers-utils/resolvers';

Example

ts
import { resolveResult, omit } from 'feathers-utils/resolvers'

app.service('users').hooks({
  after: {
    all: [resolveResult({ password: omit() })]
  }
})

Type declaration

Show Type Declarations
ts
type Result<H extends HookContext> = AnyFallback<
  ResultSingleHookContext<H>,
  Record<string, any>
>
/**
 * Resolves and transforms `context.result` using a map of resolver functions.
 * Each property in the resolver object receives the current value and can return
 * a transformed value. Runs after `next()` in the hook pipeline.
 *
 * @example
 * ```ts
 *
 *
 * app.service('users').hooks({
 *   after: {
 *     all: [resolveResult({ password: omit() })]
 *   }
 * })
 * ```
 */
export declare const resolveResult: <
  H extends HookContext = HookContext,
  R = Result<H>,
>(
  resolvers: ResolverObject<R, H>,
) => {
  (context: H, next: NextFunction): Promise<void>
  (context: H): Promisable<void>
}
ArgumentTypeDescription
resolversResolverObject<R, H>
typemethodsmulti
after, aroundfind, get, create, update, patch, removeyes

Resolver Helpers

ResolverDescription
defaults

Returns a resolver property that sets a default value when the current value is undefined or null. Accepts a static value or a function that receives the hook context.

fromPredicate

Adapts an existing predicate function (like isProvider, isContext) into a resolver condition. The predicate receives the hook context extracted from the resolver options. Only synchronous predicates are supported.

lowercase

Returns a resolver property that converts string values to lowercase. Non-string values are passed through unchanged.

omit

Returns a resolver property that removes the field by returning undefined. When a condition is provided, the field is only omitted if the condition returns true.

setNow

Returns a resolver property that sets the field to the current timestamp (Date.now()). Always overwrites the existing value.

trim

Returns a resolver property that trims whitespace from string values. Non-string values are passed through unchanged.

Conditions

ConditionDescription

Released under the MIT License.