Generics wrappers

Hi, I'm trying to have some wrapper on top of drizzle select in postgres dialect. My function looks as follow:
const find = <T extends PgTable>(table: T) {
return db.select().from(this.table);
}
const find = <T extends PgTable>(table: T) {
return db.select().from(this.table);
}
But I got an error: Argument of type 'Table' is not assignable to parameter of type 'TableLikeHasEmptySelection<Table> extends true ? DrizzleTypeError<"Cannot reference a data-modifying statement subquery if it doesn't contain a returning clause"> : Table'. What is the intended way of writing my own wrappers? Does TableLikeHasEmptySelection check is the way to check this. Seems like TS is limited in this area. I can alos see the open bug here, but no solution.
GitHub
Issues · drizzle-team/drizzle-orm
Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅 - Issues · drizzle-team/drizzle-orm
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?