Drizzle Team

DT

Drizzle Team

The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!

Join

sqlite vs postgesql vs mysql which one is faster

Can you guys send me some benchmarks ? I want store every url request in my website temprarly for builtin statistics for my svelte website What should i use for this...

Option to have relations returned from findFirst/findMany be marked as optional

In a traditional database this isn't a problem, but with Planetscale it's possible for Typescript to lie to you and have one of the returns from a with { } be undefined despite the type being defined. Is there any option to have these be marked as optional to catch this on a type level?

Delete limit and offset?

I get Property 'limit' does not exist on type 'Omit<PgDelete<PgTableWithColumns> const results = await db .delete(scheduledCalls) .where(eq(scheduledCalls.queueName, queueName))...

Relational delete with returning

Is there a way to get deleted rows back but also selecting relations? Right now we have: ``` const results = await db.query.scheduledCalls.findMany({...

TIMESTAMPTZ is returned as string instead of Date object

It seems that drizzle upon initialization (re-)sets pg-types handling of dates. Usually pg-types and thus node-postgres converts TIMESTAMP, TIMESTAMPTZ and other related data base types automatically to a JS date object. I tried Drizzle with the node-postgres driver and it didn't seem to work, dates were simply strings. I figured that Drizzle resets the default type convertes upon initialization (see picture). I was wondering why that is. And is that simply a me problem or did anyone also find TIMESTAMP being returned as string when using node-postgres?...
No description

Trying to get relations from one table to another, as one-to-many but get only one value

I have a one-to-many relation on a table, and I want to get all the workoutResults associated with a workoutSession. My query looks like this: ``` const qb = db .select() .from(workoutSession) // .leftJoin(event, eq(event.id, workoutSession.eventId));...

strange libsql error when doing push:sqlite

error message and code: https://pastebin.com/EnqkHYCd tutorial that i'm following: https://www.youtube.com/watch?v=cpzowDDJj24 this is my first time using Drizzle and Turso so i would really appreciate if someone could help me :)...

Relations include query

For example If I have the following schema: `export const sales = mysqlTable("Sales", { id: int("id").autoincrement().notNull(), startingDate: datetime("starting_date", { mode: 'string'}).notNull(),...

Issue with Drizzle-Zod: Due to a type mismatch between the ZodObject and ZodType types.

I have issues with this part of the code "due to a type mismatch between the ZodObject and ZodType types. The ZodObject type is missing a readonly property that is required by the ZodType type": export type Media = z.infer<typeof updateMediaSchema>; export type NewMedia = z.infer<typeof insertMediaSchema>; export type NewMediaParams = z.infer<typeof insertMediaParams>;...
No description

Possible to reuse columns while selecting?

Apologies if this is documented somewhere and I've missed it I am currently in the process of transitioning from Prisma and follow this pattern quite often: ```ts...

Manually create migration file

Is it possible to manually create a migration file like the way prisma has it? basically just creating a sql file that is part of the migration but it does not get executed. I'm asking this because I want to create a migration file for a raw materialized view since views arent supported

How do you infer the type of a relations query?

I tried infer model and schema but it misses the relations created

Possible to select* off of Joined table?

Consider this SQL query ``` SELECT sb.* FROM books b...

ForeignKey Too Long

Hi Drizzle Devs ! I would like to know if you are working on the functionnality to customize fk naming because i can't fully migrate because my foreign key is too long...

Drizzle workflow on schema modification

Hi, can someone explain me the process to follow when we modify the schema to push modifications to database please. I'm working on 2 computers, and when i modify schema like adding constraints, when i go to my second computer, i run drizzle-kit introspect:mysql and push:mysql but no modifications are added, also if i drop my table and recreate it with drizzle push:mysl, constraints are not added to my tables....

Possible to have type from enum value?

Has you can see i am filtering all my users by type "clinician", supposedly its 100% sure that the output of this would be that the user type is "clinician", but it still picks up the other enum possibilities, is it possible to make it understand in the type inference that the user type will only be "clinician"?
No description

Creating join table that is simultaneously many-to-many and one-to-many

got a data modeling / sql question for you all: I have an entity A with either a many-to-many relationship to B, or a one-to-many relationship to C. There must be a unique ordering of all relationships from A to B or C, such that we can define an ordering such as B1, B2, C1, B3, C2... etc B and C are different entities, with wildly different table structures, and therefore cannot be combined into a single table. ...

Any way to replace null by undefined?

Before using Drizzle, I was using the type mapper and the transform option of postgres.js in order to transform undefined to null. That way, any inserted undefined would be inserted as null in the database, and any null value in the database would be an undefined in JS. I'm looking for a way to do this with Drizzle. AFAIU as I'm still using the postgres.js connector, I can continue with these options, so the issue is to use undefined instead of null in the types. Similarly to changing a column type with .$type<T>(). Thanks!...

Drizzle pagination with count

Hi, is there a way to have a paginated query that also count all posible results based on a condition? I have the following currently: `const result = await db.query.businessUsers .findMany({ orderBy: businessUsers.id,...

TRIGGERS in Drizzle

Is there a way to define/implement TRIGGERs in Drizzle? An example would be great!...