You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to install and use this hooks on a Directus (v9 - the node version) project.
Can't get it to load properly. I'm following the steps and import knex-hooks in the database file. When running it throws some errors:
npm run dev
[ERROR] 15:07:56 ⨯ Unable to compile TypeScript:
src/database/index.ts:53:10 - error TS2339: Property 'addHook' does not exist on type 'Knex<any, unknown[]>'.
53 database.addHook('before', '*', '*', (when, method, table, params) => {
~~~~~~~
src/database/index.ts:53:39 - error TS7006: Parameter 'when' implicitly has an 'any' type.
53 database.addHook('before', '*', '*', (when, method, table, params) => {
~~~~
src/database/index.ts:53:45 - error TS7006: Parameter 'method' implicitly has an 'any' type.
53 database.addHook('before', '*', '*', (when, method, table, params) => {
~~~~~~
src/database/index.ts:53:53 - error TS7006: Parameter 'table' implicitly has an 'any' type.
53 database.addHook('before', '*', '*', (when, method, table, params) => {
~~~~~
src/database/index.ts:53:60 - error TS7006: Parameter 'params' implicitly has an 'any' type.
53 database.addHook('before', '*', '*', (when, method, table, params) => {
I guess Directus can't load the module. All the other node_modules have a different structure.
Anyone got this to work, in any project type?
The text was updated successfully, but these errors were encountered:
Hey, knex-hooks is missing typescript declarations and this is why TS can't compile your code because it does not know that knex is pacthed and have new method "addHook".
For now you have to manually declare knex method addHook(...) in your code.
Thanks for getting back to me in this issue. Sorry for my late response...
I'm not sure I understand. Could you please give me some more simple info/guides on how to setup these hooks (and helpers) in a Node (Express) project like Directus v9?
I'm trying to install and use this hooks on a Directus (v9 - the node version) project.
Can't get it to load properly. I'm following the steps and import knex-hooks in the database file. When running it throws some errors:
npm run dev
I guess Directus can't load the module. All the other node_modules have a different structure.
Anyone got this to work, in any project type?
The text was updated successfully, but these errors were encountered: