Hooks
checkMultiCheck if the 'multi' option is set for a method. You can use this to early throw an error if 'multi' is not set.
checkRequiredCheck selected fields exist and are not falsey. Numeric 0 is acceptable.
combineSequentially execute multiple hooks.
createRelatedCreate related records in other services.
debugDisplay the current hook context for debugging.
disablePaginationDisables pagination when query.$limit is -1 or '-1'.
disallowPrevents access to a service method completely or for specific transports.
iffExecute one or another series of hooks depending on a sync or async predicate.
iffElseExecute one array of hooks or another based on a sync or async predicate.
onDeletehook to manipulate related items on delete.
This can be handled by your database, but this hook allows you to do it in your application logic. Then you get service events and hooks for the related items.
paramsForServera hook to move params to query.$client
the server only receives 'query' from params. All other params are ignored.
So, to use $populateParams on the server, we need to move the params to query.$client
the server will move them back to params
paramsFromClientPass context.params from client to server. Server hook.
preventChangesPrevent patch service calls from changing certain fields.
setDatahook to set properties on context.data
setFieldThe setField hook allows to set a field on the hook context based on the value of another field on the hook context.
setResulthook to set properties on context.result
setSlugFix slugs in URL, e.g. /stores/:storeId.
skippableWrap a hook to make it skippable
softDeleteAllow to mark items as deleted instead of removing them.
stashBeforeStash current value of record, usually before mutating it. Performs a get call.
throwIfThrow an error if the predicate function returns true.
This hook is useful for validating conditions before proceeding with the request.
throwIfIsMultiThrow an error if the context is multi. You can use this to early return if a user provides an array on create or id:null on patch or remove.
throwIfIsProviderThrow an error for certain transports.
transformDataMake changes to items in context.data. Very flexible.
transformQueryTransforms the query object.
transformResultMake changes to items in context.result. Very flexible.
traverseTransform fields & objects in place in the record(s) using a recursive walk. Powerful. Check docs at https://github.com/substack/js-traverse for info on transformContext!
unlessExecute a series of hooks if a sync or async predicate is falsy.
