RobinBlomberg / kysely-codegen

Generate Kysely type definitions from your database.
MIT License
808 stars 73 forks source link

[Feature] Customizable generated table type names #122

Open bombillazo opened 11 months ago

bombillazo commented 11 months ago

Hello,

We have a use case where we need the Generated Kysely type to have either a suffix or prefix to differentiate it from our application types representing the same resource. It would be great to be able to specify an suffix like Table to all generated types so our IDE can auto import and identify types correctly and discriminate from our custom types.

Upvote & Fund

Fund with Polar

shane-js commented 4 months ago

It would be great to be able to specify an suffix like Table to all generated types

I am just getting started with kysely/kysely-codegen but I was actually expecting this to be the default behavior as per kysely getting started docs ( https://kysely.dev/docs/getting-started?package-manager=npm ) types section it is actually shown specifically to "not use the table schema interfaces directly" and we can see in their code examples they way they demonstrate distinguishing is by having the database table interfaces have suffix of 'Table' and exporting the wrapped Selectable type as the table name alone.

@RobinBlomberg Would you be open to this being the default behavior in general separate from this requiring an ability to customize it? Obviously that could be seen as a breaking change for folks who have built their flows around it not having the 'Table' suffix.

bombillazo commented 3 months ago

Hey, yeah we currently have a post-process that will edit the files after they have been generated, would be great if this was done natively for sure.