Reusable pgTable column helper - losing type : [x: string] instead of user_id
Hi, I am trying to create a reusable column to use accross multiple tables. If I use the following :
I get the correct type in my KyselyDatabase interface.
user_id: ColumnType<string, string, string>;
I'd like it to be a function instead. But when I do the following :
I get the following type (thus breaking types accross all my db queries)
[x: string]: ColumnType<string | null, string, string>;
4 Replies
When I use a var :
char(name...)
I have a return type of <PgCharBuilderInitial<string ...
and if I use directly char("user_id")
, I get the correct one : <PgCharBuilderInitial<"user_id" ...
Use a generic:
Thanks a bunch!!! Works perfectly.
hello ,
please i'm trying to do something similar but i'm getting a circular dependency
here is where i define the shared columns :
error:
FYI: each table is defined in a single file (i'm using a barrel file to export the hole schema )