Customize collections with NestJS mounted application


I’ve got a beta agent mounted on my NestJS app, as described in this part of documentation - Forest Admin - [Beta] Developer guide
Data source is SQL (no orm), though nest server uses Typeorm.

My goal is to add a Before Create hook to one of my tables.
It’s not quite clear for me from the documentation - where exactly this .addHook() method should be called on the table, since currently my app doesn’t have any files generated over my Nest infrastructure, except only .forestadmin-schema.json.
And the database schema is described by typeorm @Entity decorated classes.

Thanks in advance!

Hello, and welcome to the new agent :slight_smile:
The agent will always only generate the .forestadmin-schema.json file. It does’t generate any code.
The .addHook will be triggered after an action. Below, the list of arguments.

For example, you can trigger the code defined is the hook before the create action.

The Hooks will not be executed if you don’t call the forestadmin abstraction. For example, if you call myCollection.create(...), it is works but if you run a SQL query or TypeOrm the hook will be not triggered.

An example to customize a collection and this one.