Drizzle Team

DT

Drizzle Team

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

Join

MySQL (Planetscale): Cannot read properties of undefined (reading 'name')

Hi Hopefully someone can help me. I'm getting the above error in my insert query. ```ts...

Deploying Next.js w/ Drizzle on Vercel with Turborepo

I have a turborepo with Next.js using drizzle-orm as a shared package. A bit of context - I'm using a monorepo with drizzle and share the tables, types and schemas across all my apps by having a shared packages/database library - that my Next.js app is consuming. One issue I've had is that in order to get drizzle-orm working in my monorepo I've had to install it globally ie. in my root level package.json. ...

uuid missing in drizzle-orm/mysql-core?

There is a uuid method in the drizzle-orm/pg-core package, but none in the mysql-core package. What is the reason behind this? What should we use instead to generate uuids automatically?

DatabaseError: Duplicate column name 'id'

hey guys, i have a problem in my query but cannot figure out what is causing it. ```ts const coursesSq = db .select({...

numeric returns string when querying with Postgres

``` export const order = pgTable( 'orders', { ... totalValue: numeric('total_value', { precision: 10, scale: 2 }),...

Need help transform a nested prisma query to drizzle

Hey I'm trying to translate the following prisma query to drizzle: ```ts const invite = await prisma.invite.findUnique({ where: {...

Type error for eq()

I get Expected 1 arguments, but got 2. in a statement like this:
.where(and(eq(menu.id, form.data.id)), eq(menu.userId, session.userId));
.where(and(eq(menu.id, form.data.id)), eq(menu.userId, session.userId));
...

InArray Function not Working

Why is the drizzle Function inArray mapping my array from ['1ed01d30-d16d-4b8f-b5d0-01b2a5d94d13', '37fdf74f-4069-4eab-8eee-5ad282c66667'] to (('1ed01d30-d16d-4b8f-b5d0-01b2a5d94d13', '37fdf74f-4069-4eab-8eee-5ad282c66667')) the Double brackets are messing everything up what is goin on

Raw sql nullable types, sql<Type | undefined>

const result = await db.select({
customField: sql<Type | null>`...`
const result = await db.select({
customField: sql<Type | null>`...`
...

Using with NestJS and Zod

I'm trying to use drizzle-zod and nestjs-zod together to create Zod schemas and classes for insert and select. I mostly got it to work, even with Swagger! However, I'm running into a problem with one of the create schemas. My table is defined: ```ts export const addresses = pgTable('addresses', { id: uuid('id').defaultRandom().primaryKey(),...

Many-to-Many joins results in weird values

Hey, I am new to Prisma, switching here from prisma so I can use a typesafe orm with D1 properly. I am trying to return a many-to-many joined result: ```ts const teamedUser = await db.select().from(usersToTeams) .where(eq(usersToTeams.user, user.id))...

Is drizzle fully framework agnostic?

I saw a lot of people use drizzle in NextJS, but i didn't find a lot of information about usage in frameworks like Nuxt 3 or Sveltekit. Are there things that need to be done diffrently depending on the framework?

Typing columns based on Table

I'm trying to make a generic paginateQuery function that would let me pass in the table and then an array of only columns from that table would be accepted. Is there any way to do this with the Drizzle types? I feel like I have gotten close a few times but nothing fully gets there. Thanks! ```ts const getFilterSql = <TColumn extends AnyPgColumn>( filter: string,...

Does onConflictDoUpdate work with composite primary keys?

I have a model defined below: ```ts export const userDevices = pgTable( 'user_devices',...

Support for multiple with statements?

Is it possible to have multiple with statements? ``` const carriers = await tx .with(carrierTaskCount)...

use constant in between operator

Hello guys, Is there any way to use constant in between filter instead of column?...

Type error: Could not find a declaration file for module 'drizzle-kit'.

Any idea how to fix this problem? I try to run this: npm i --save-dev @types/drizzle-kit: npm ERR! Cannot read properties of null (reading 'matches')...

Typescript error that doesn't make a whole lot of sense when calling db.select or db.insert

This is my account model ``` export const accounts = mysqlTable("accounts", { id: nanoid("id", {}).primaryKey(), userId: varchar("userId", { length: 25 }),...

Are default values not transferred over via drizzle-zod?

It seems like when I use a default([]) in my schema file that when I create a Zod object, I have to re-do the defaults?