Se7enVision
Se7enVision
DTDrizzle Team
Created by Se7enVision on 4/4/2024 in #help
How to add where clause for one to one relations in drizzle query?
@Aaroned Thanks I'll look into it.
6 replies
DTDrizzle Team
Created by Se7enVision on 4/4/2024 in #help
How to add where clause for one to one relations in drizzle query?
Hey @Aaroned Thanks for the response. This would work fine but I have several other relations which I am using with users table to get my data. I only shared the Payment one to shorten the question. I have a datatable in which I have to render users along with user related info present in other tables, so I can only do db.users.query in order to accomodate for them. This is how my complete query looks like: const users = await ctx.db.query.users.findMany({ with: { albums: { columns: {}, with: { tracks: true, MusicVideo: true, } }, ......bunch of relations Payment: { columns: { planName: true } } }, where: !operator || operator === "and" ? and( ...where, filters?.planName ? eq(payment.planName, filters.planName) : undefined, ) : or( ...where, filters?.planName ? eq(payment.planName, filters.planName) : undefined ), limit: input.limit ?? 10, offset: input.offset ?? 0, }) The line filters?.planName ? eq(payment.planName, filters.planName) : undefined obviously does not work and gives the error 'user.planName is unknown' which it is in this context. So I have to use above method for it.
6 replies
DTDrizzle Team
Created by Se7enVision on 4/4/2024 in #help
How to add where clause for one to one relations in drizzle query?
One solution I found is adding this in WHERE clause : sqlid IN (SELECT userId from Payment WHERE planName=${plan}). But I would appreciate a cleaner solution
6 replies
DTDrizzle Team
Created by Se7enVision on 3/28/2024 in #help
Case sensitivity issue with planetscale
No description
2 replies