G$Row
G$Row
Explore posts from servers
DTDrizzle Team
Created by G$Row on 7/23/2024 in #help
I'm getting a Postgres Error when running my drizzle query but not when running the generated sql
I figured out a way around it.
switch (timeFrame) {
case "day":
dateExpression = sql`DATE(${Appointment.checkedOutAt})`;
break;
case "week":
dateExpression = sql`DATE_TRUNC('week', ${Appointment.checkedOutAt}) `;
break;
case "month":
dateExpression = sql`DATE_TRUNC('month', ${Appointment.checkedOutAt}) `;
break;
case "year":
dateExpression = sql`DATE_TRUNC('year', ${Appointment.checkedOutAt}) `;
break;
}
switch (timeFrame) {
case "day":
dateExpression = sql`DATE(${Appointment.checkedOutAt})`;
break;
case "week":
dateExpression = sql`DATE_TRUNC('week', ${Appointment.checkedOutAt}) `;
break;
case "month":
dateExpression = sql`DATE_TRUNC('month', ${Appointment.checkedOutAt}) `;
break;
case "year":
dateExpression = sql`DATE_TRUNC('year', ${Appointment.checkedOutAt}) `;
break;
}
If I use a switch statement and not pass in the timeFrame as a parmeter it works. I'm not sure if this problem is a bug in the driver or in drizzle
4 replies
DTDrizzle Team
Created by G$Row on 7/23/2024 in #help
I'm getting a Postgres Error when running my drizzle query but not when running the generated sql
Not sure why
4 replies
DTDrizzle Team
Created by G$Row on 7/23/2024 in #help
I'm getting a Postgres Error when running my drizzle query but not when running the generated sql
Ok so it seems that having the time frame be put in the sql string staffDateExpression is where the problem comes from. It doesn't recognize that they are the same for some reason.
4 replies
DTDrizzle Team
Created by hachoter on 6/27/2023 in #help
What is the type of transaction prop?
If anyone else runs across this here's what worked for me. This is an easy way to get the actual transaction type. (Using typeof db may work but it isn't the same.) tx: Parameters<Parameters<typeof db.transaction>[0]>[0]
5 replies
DTDrizzle Team
Created by Arthur Danjou 🧸 on 4/17/2024 in #help
Migration from prisma to Drizzle
Which part of it are you having trouble migrating?
6 replies
DTDrizzle Team
Created by Bryan3 on 9/28/2023 in #help
How to include all fields in partial select syntax
Is there a way to do this with the columns of a subquery?
10 replies
DTDrizzle Team
Created by G$Row on 11/8/2023 in #help
Getting "never" type from querying a relation
It is never explicitly stated in the docs (as far as I can tell) that you must include the relations in the schema. You have to infer it based on the "Querying" section of the Query page. The first code snippet has index.ts and schema.ts tabs. The way I figured it out was by the line "import * as schema from './schema'; Then when I clicked on the schema.ts tab I noticed that the relations were there. Maybe a short sentence in that section that says the relations must be included as part of your schema could make things a bit more clear.
5 replies
DTDrizzle Team
Created by G$Row on 11/8/2023 in #help
Getting "never" type from querying a relation
Figured it out. I have my table models in different files and I import them all to create the final schema with which I can create the db object. Turns out I was only adding my table models to the schema and not the relations as well. After adding the relations to the schema it was fixed].
5 replies