Skip to content

skipResult

utils
Source Code | Documentation

Sets context.result to an appropriate empty value based on the hook method. Returns an empty paginated object for paginated find, an empty array for multi operations, or null for single-item operations. Does nothing if a result already exists.

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

Example

ts
import { skipResult } from 'feathers-utils/utils'

// In a before hook to skip the actual database call:
skipResult(context)

Type declaration

Show Type Declarations
ts
/**
 * Sets `context.result` to an appropriate empty value based on the hook method.
 * Returns an empty paginated object for paginated `find`, an empty array for multi
 * operations, or `null` for single-item operations. Does nothing if a result already exists.
 *
 * @example
 * ```ts
 *
 *
 * // In a before hook to skip the actual database call:
 * skipResult(context)
 * ```
 *
 * @see https://utils.feathersjs.com/utils/skip-result.html
 */
export declare const skipResult: <H extends HookContext = HookContext>(
  context: H,
) => H
ArgumentTypeDescription
contextH

Released under the MIT License.