Drizzle Team

DT

Drizzle Team

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

Join

Unexpected identifier 'TABLE'

I used drizzle-kit generate:pg to generate this schema ```sql CREATE TABLE IF NOT EXISTS users ( user_id INT PRIMARY KEY, username VARCHAR(255),...

How to join tables from different dbs in same db cluster?

Hi is there the possibility to join tables from different schemas? We have a mariadb cluster with different schemas and would like to join tables from different schemas. Is that already possible with drizzle?...

Why is my query so much slower when filter by all four latitude/longitude bounds than just three?

When I uncomment out any of the latitude / longitude filters, the response latency spikes from ~50ms to 2000ms. (a similar query on prisma runs in just ~60ms, even with all filters.). Does anyone have an idea why? Or how I could fix this? Unfortunately, migrating to PostGIS is not an option at the moment ```typescript const facilities = await db.query.facility.findMany({ orderBy: desc(facility.internalRating), limit: 1,...

Enum type gets lost

Setup: I have a server-side db schema definition which I push with bunx drizzle-kit push:sqlite and pull on the website with bunx drizzle-kit introspect:sqlite in my schema definition I have the following table ```ts...

Hey I looking for the documentation of the `get()` methods

I ran into this code https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-drizzle/src/lib/sqlite.ts#L105 where they are using get() a lot. I could find the documentation for it? anyone as any idea what it does or how to use it?...

No query result types

When i'm doing this.conn.query.organizations.findMany({}) there is no autocomplete for organizations columns, it shows only relations (restaurants) this.conn is PostgresJsDatabase<typeof schema> But if i specify ```...
No description

Help migrating raw query from prisma to drizzle

Trying to get the below query which has multiple joins into drizzle. It's one of the last ones I have and I am not sure if I should go the route of query or select. Query didnt have or show any docs on joins. Whats the optimal way to do this and is it possible to do also the count in the same query or will that still have to be an extra or separate? `` const results: any = await prisma.$queryRaw...

Dropping mysql unique errors

Hello! I saw there were already an issue created for it https://github.com/drizzle-team/drizzle-orm/issues/998 database: mysql...

drizzle-zod object scoped refine

I would like to check an objects multiple columns. For example whether password field is equal to confirmPassword filed. With zod it was a .refine() after a z.object(), but I cant get it work with createInsertSchema() Is there any workaround to work with react hook forms?...

connection ECONNREFUSED when trying to push to neon db

Hi people, I'm trying to connect my next.js app with drizzle to neon db, but I'm getting this error when i run push:pg ```bash...

Setting connectionString from env in sveltekit

I've been trying to get my connection string from .env into the drizzle.config.ts file, but vite aliases are not working within the file, so i cannot access the aliased sveltekit env variables. I really don't want to export the variable as VITE_ since that could be a security risk in the future....

turso geospatial and fuzzy search using extensions

There's an option to create a database with some of the extensions enabled that are kinda barebones. I don't know how to use those to begin with much less through the ORM. https://github.com/nalgeon/sqlean/blob/main/docs/fuzzy.md

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(),...