Drizzle Team

DT

Drizzle Team

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

Join

Is typescript slow for anyone else?

Typescript is incredibly slow for anything related to drizzle, I have an m1 macbook pro with decent memory so I don't think it's my machine, is anyone else experiencing this or is it unrelated to drizzle

TypeError when adding subquery to `drizzle.insert.values`

Hey all, I'm a bit new to drizzle so not sure if this is even possible or if I'm just doing something wrong. I'm getting type errors when using a subquery to select for companyId based on a company name: ```ts return await db.insert(widgetItem).values({ name: "New Widget",...

Error on Vercel with drizzle

I have everything setup and working locally with my new remix application which uses drizzle. However, when I deploy to vercel as soon as I try to login I get the following error when I reach the part where my code calls db.select()... Has anyone seen this or could point me in the right direction....
No description

Anyone have a project with Drizzle + Neon in Next.js?

Anyone done a project with drizzle + neon in next.js that you can share?

Infer Type from PgEnum

Hey, I'd like to infer a PgEnum to a TypeScript Type. So something like this: ``` const eventTypeEnum = pgEnum('event_type', [...

net::ERR_NAME_NOT_RESOLVED

Hi, I was following the drizzle planetscale starter made by josh (https://github.com/joschan21/drizzle-planetscale-starter) and I came across some erros I didn't know how to fix. I have the following server component: ``` import { db } from "app/lib/db/index";...

@vercel/postgres & drizzle update?

Looks like const db = drizzle(sql) does not work anymore with the latest version of drizzle & @vercel/postgres. Anyone else seeing this and have a solution? drizzle is looking for VercelPgClient but sql is now typed to Vercel pool...

many-many with

Hi. I have a schema with users, roles and user_to_roles tables. I also have a usersRelations object, created with: ```ts export const usersRelations = relations(users, ({ one, many }) => ({ usersToRoles: many(usersToRoles),...

help with drizzle implementation on streaming service overhaul

Hi Drizzle discord users, I recently started using typescript and next Js and would love to use drizzle for a personal project. It’s for a revamp of my local tv stations web player. I would like to use drizzle to overhaul the db. I came up with this json return format last night and think I could be a good working ground. I love the idea of relational queries but I have no idea even what tables to create. Here is the json https://c9rlvz.csb.app/db-return.json...

different `where` but same return type for relational queries?

what's the best way to approach it when i have a fair few relational queries that have different where: clauses, but are otherwise the same (or extremely similar)? ```ts public static async queryPostsByWantsItemId(itemId: number) { return await db.query.posts.findMany({ /* different v */...

Optional filtering

I'm trying to figure out the right pattern to reproduce an SQL query where the user can optionally filter based on a column value. For example, assuming a chunks table with a documentId column, you could write the query
SELECT * FROM chunks WHERE ($1 IS NULL OR chunks.documentId = $1);
SELECT * FROM chunks WHERE ($1 IS NULL OR chunks.documentId = $1);
...

Any way to do migrations with data

Looking for ways to insert data into the database as part of the migration. It appears it's unsupported but seems like this would be another nice-to-have feature.

Filtering findMany using related records

I have a restaurants table that has a one-to-one relation with an addresses table. I want to pull all of the restaurants and their address within specific lat/long bounds, but I'm struggling to figure out how to do that. A simplified version of what I want/have so far ```ts await this.drizzleService.db.query.restaurants.findMany({ where: (table) => and(between(/* what could I use here to specify table.address.latitude */, minLat, maxLat)),...

Drizzle Kit Push & Generate gives weird error

I get the following error: ```ts { detail: undefined,...
Solution:
This fix seemed to work ```ts //tsconfig.json {...

re-formatting duplicated data

so i have a db with the schema shown below a userPost object consists of the following: ```...

Transforming const to the configured target environment ("es5") is not supported yet

Below is my schema file. `import { InferModel } from 'drizzle-orm' import { mysqlTable, serial, text, timestamp } from 'drizzle-orm/mysql-core' ...

nested relation queries

```graphql userPost: { id, description, createdAt,...

CommonJS import error

I'm using drizzle inside of a scipt the is commonJS. ``` node version: v18.16.0 drizzle-orm: 0.26.5...

Unable to delete all rows from SQLite using Transactions?

i have a route api/delete-all that looks like: ```ts import { NextResponse } from 'next/server' ...