RobinBlomberg / kysely-codegen

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

Override `Date`/`TimeStamp` types with custom types #218

Closed bombillazo closed 3 weeks ago

bombillazo commented 1 month ago

Hey, perhaps this is not the best way to ask this but, is there any way we can implement this change without having to patch the library?

We basically need to create custom date/time types for our DB kysely tables column types. Is there any way this can be configured during runtime?

bombillazo commented 3 weeks ago

Any help @RobinBlomberg ?

RobinBlomberg commented 3 weeks ago

Hello @bombillazo! There is the --overrides CLI flag that can be used for specifying custom column types, but it's a bit unwieldy to use. However, I will release a new version shortly (within a week) that will allow you to do it even more easily using a .kysely-codegenrc.(json/js/ts) configuration file. It will also support extending/overriding internals like the serializer or transformer for inserting more advanced custom logic.

I will close the PR as I don't intend to change the base types, but I hope you can implement them yourself in the config soon!

bombillazo commented 3 weeks ago

Awesome news to hear, we'll keep our patch until that new update is released. Thanks for the quick response!