how to get generic table type
I tried to use AnyPgTable type to make dynamic function
but i need to have id type
all tables have serial id column
1 Reply
This might help you
https://orm.drizzle.team/docs/goodies
Also, you might have to pass in the expected return type as a generic:
const result = await findById<UserTableType[]>(id, usersTable);
imo, your function is too generic you should just make getById
functions for each of your tables. getUserById
getPostById
etc..Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.