Utils
addSkipAdd names to context.params.skipHooks for skippable hooks.
addToQuerySafely adds a property to a query object. If the property already exists, it adds it to the $and array.
If the exact same property-value pair already exists, it does nothing.
checkContextRestrict a hook to run for certain methods and method types.
contextToJsonConverts a FeathersJS HookContext to JSON.
If the context has a toJSON method, it will call that method.
Otherwise, it will return the context as is.
This is useful for serializing the context for logging or debugging purposes. E.g. when you use 'has'/'get' from lodash to access properties of the context.
defineHooksTypescript helper function to define hooks with type safety.
getDataIsArrayAlways returns the context.data as an array.
If context.data is not an array, it will be wrapped in an array.
getExposedMethodsLittle helper to get methods are publicly exposed by a service.
getPaginateutil to get paginate options from context
- it uses
context.params.paginateif it exists - it uses
service.options.paginateif it exists - it uses
context.params.adapterif it exists
iterateFindUse for await to iterate over the results of a find method.
This function is useful for iterating over large datasets without loading everything into memory at once. It uses pagination to fetch results in chunks, allowing you to process each item as it is retrieved.
patchBatchBatch patching utility that takes an array of items to be changed and returns an array of arguments to be called with the patch method.
This utility is useful when you need to patch multiple items with varying data in as few requests as possible.
skipResultSet context.result to an empty array or object, depending on the hook type
transformParamsSafely use a transformParams function to modify params.
walkQueryWalks the given Feathers query and calls the walker function for each property. The
walker function can return a new value which will replace the original value in the
returned query. If no changes were made the original query will be returned.
