Closed vonagam closed 5 years ago
I also think we need to support v4, and We need to keep this project as simple as we can.
Regards to 2), can you explain a little more how someone can do which is asked in #120 with client.hooks (so we can add your PR and put more clearly how to manage it @DanStorm )
Ok. Based on #121 and #126 here is a description of what i think he wants to do: for every service call (except for create
and remove
) change params
to have { $ignoreDeletedAt: true }
in params for a server using paramsForServer
. Here is the code based on that description:
const { paramsForServer } = require( 'feathers-hooks-common' );
const hook = ( context ) => {
if ( context.method === 'create' || context.method === 'remove' ) return;
context.params.query = paramsForServer( {
query: context.params.query,
$ignoreDeletedAt: true,
} ).query;
};
client.hooks( { before: hook } );
This will do it for any resource/service. If you want this custom hook to run only for specific service use client.service( name ).hooks( { before: hook } )
.
The code above needs to be ran before a feathers client is passed to restClient
.
This works great! Thank you gentlemen, that was awesome of you!
Not that you need it, but you have my full endorsement to remove the softDelete option. I've closed #126
great @vonagam , merging this now!
Support
@feathersjs/client
of version 4 (fix issues #123 and #124).Undo
softDelete
functionality introduced in #121 for issue #120. For two reasons:1)
feathers-hooks-common
does not support v4 yet and it is unknown when it will be.2) Functionality to modify
params
/data
/id
(which was asked in #120) is already present without additional options and code in this package -hooks
. Just useclient.hooks(...)
orclient.service(path).hooks(...)
for custom logic.