Replies: 1 comment
-
If you want a type system that is easy to use, you will need to switch to Prisma. I figured I would do one more search for answers before making the switch myself. If you want to add types to the input / output of the functions you write to wrap Drizzle operations it's extremely difficult to figure out. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanna create a dynamic select statement, adding different fields based on conditions. I copied an example from the docs, but the types don’t seem to work. How do you handle this?
function withUser<T extends PgSelect>(qb: T) { return qb.leftJoin(schema.users, eq(schema.products.userId, schema.users.id)); }
let query = this.db.select().from(schema.products).limit(10).$dynamic();
if (params.includes.includes('user')) { query = withUser(query); }
Beta Was this translation helpful? Give feedback.
All reactions