Replies: 4 comments
-
Same issue... |
Beta Was this translation helpful? Give feedback.
-
Same issue |
Beta Was this translation helpful? Give feedback.
-
I have been using I just dumped a thing I'm working on for my own project where I want to have reusable functions that I can just pass my table schemas into - it's completely untested at this time, but I did a lot of work this week to figure out the Drizzle types. Check this comment for the small gist of it - #1644 (comment) - and expand the EDIT section to see the solution. And here's the dump including today's progress - https://gist.github.com/waynesbrain/707547d58fda5f33bc452a8fdf54516a |
Beta Was this translation helpful? Give feedback.
-
I had this same isssue , so i created some thing like this maybe this will help export async function getRecordById<T extends Table>(table: T, id: number) {
try {
const tableName = getTableName(table);
const query = sql`select * from ${sql.raw(tableName)} where id = ${id} AND is_deleted = false limit 1`;
const result = await db.execute(query);
return result.rows;
} catch (error) {
console.error("Error fetching record ", error);
throw error;
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I tried
AnyPgTable
, which works fine withinsert()
but fordb.select().from()
I get an error onfrom()
Beta Was this translation helpful? Give feedback.
All reactions