stashBefore
Source Code | DocumentationStashes the current value of a record into params.before prior to mutation. Performs a get (single item) or find (multi) call to retrieve the existing state. Useful in update, patch, or remove hooks when you need the original data for comparison.
ts
import { stashBefore } from 'feathers-utils/hooks';Example
ts
import { stashBefore } from 'feathers-utils/hooks'
app.service('users').hooks({
before: { patch: [stashBefore()] }
})
// Access via: context.params.beforeType declaration
Show Type Declarations
ts
/**
* Stashes the current value of a record into `params.before` prior to mutation.
* Performs a `get` (single item) or `find` (multi) call to retrieve the existing state.
* Useful in `update`, `patch`, or `remove` hooks when you need the original data for comparison.
*
* @example
* ```ts
*
*
* app.service('users').hooks({
* before: { patch: [stashBefore()] }
* })
* // Access via: context.params.before
* ```
*
* @see https://utils.feathersjs.com/hooks/stash-before.html
*/
export declare function stashBefore<H extends HookContext = HookContext>(
fieldName?: string,
): (context: H, next?: NextFunction) => Promise<any>| Argument | Type | Description |
|---|---|---|
| fieldName | string |
| type | methods | multi |
|---|---|---|
| before, around | get, update, patch, remove | yes |
