Drizzle Team

DT

Drizzle Team

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

Join

Typescript path alias not working properly

I'm new to Drizzle, but I'm not able to use the path alias on schema files. Using absolute paths on the imports works without a problem, but when using any @/... path everything breaks. Right now I'm working around this problema by denying @/ imports wit ESLint but that is not a good solution long term....
No description

Expand query from ID using .select()

Hi! I am trying to get the first name of a comment author, but only store the ID so the user can change their name. Here's my schema.ts ```typescript import { InferModel, relations } from "drizzle-orm"; import { pgTable, text, varchar, bigint, json } from "drizzle-orm/pg-core";...

PGEnum -> Typescript Enum

Hey there. Is there any convenient way people have found to conveniently turn a pgEnum into a typescript enum such as below? Currently I'm creating DTO's but i figured coupling them would be much easier :). I figure ZOD might come into play but we are utilizing NestJS w/ class-validator atm. ``` const typeEnum = pgEnum('type', [ 'short_text',...

Is Drizzle Kit/Drizzle Studio possible with RDS Data API?

I'm able to create the RDSDataClient for querying my DB using Drizzle ORM, but I don't see a way to use Drizzle Kit for DB inspection/push or Drizzle Studio for data exploration. The drizzle.config.ts seems to only make it possible to use the DB connection URI/params. Is there a way to still have these interactions with my RDS db if I'm using the Data API?...

How to apply migrations on postgres in a serverless enviroment?

Hello, I want to apply postgres migrations to my vercel DB. I see that the push command does not work for postgres and am therefore attempting to use the migrate function like so: ```ts...

Error when trying to generate a migration schema

anyone any ideas to what the problem is? It was working fine yesterday and now it throws an error when I am trying to generate a migration file. I was updating the relationships/adding a new table and when I tried generate a migration file, this error appeared this is the script i'm running "generate": "cross-env NODE_ENV=development drizzle-kit generate:pg --config=drizzle.config.ts", ...

Modelling self relations

I have a table categories with a parent fields: ``` { id: text("id").notNull().primaryKey(), .... ...

Issue running migrations to DB

I am having an issue running migrations to Neon. I checked that everything is exporting const variables and tried add the cjs version of drizzle kit and reinstalling node modules.. but no luck fixing it I also tried to run a migration on a new db and its still giving me the same error. not sure whats going on ```ts...

It is possible to have prepared statements inside transactions?

Is there a way to insert prepared queries inside a transaction ?

type config findMany or findFirst

Hi, I've one question i don't find the way to type correctly findMany() Like: export async function findAll({...

Any idea on how to pass a pool from postgres-pool to drizzle?

Passing a single client works, but for better connection management it would help to be able to pass the pool.

How to get another linked tables count?

I am new to Drizzle ORM and I wanted to get another tables data in my api. This is my api ```ts import { eq } from "drizzle-orm";...

I created a next auth adapter for postgres-js

The open PR was not working for me so I created a new adapter. I added it to a starter project so people can take it. This is temporary until we get an official plugin. I WILL NOT provide any support for this or maintain this repo https://github.com/c-karaolis/drizzle-next-auth-adapter-postgres

.prepare() in Next.js App Router

Hello! I'm trying to use PostgresQL prepared statement in the Next.js App Router and I have been getting stuck on "prepared statement already exists" Does anyone have an example I can refer to? It'd be a lot of help!...

Deleting records w/ sqlite-core.

Hello all, hoping to find some clarity/direction. So I'm trying to delete a record using; ```ts export async function acceptUserMail(mailItem: string) { return db.delete(mailbox).where(eq(mailbox.id, mailItem)).run(); }...

Can't figure out how to design relational query

I have three tables - categories - products - media ...

[email protected] with [email protected]

added drizzle-zod to my project and I am getting this error when starting the dev server - error ./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/drizzle-zod/index.mjs Attempted import error: 'is' is not exported from 'drizzle-orm' (imported as 'n'). ...

ERR_MODULE_NOT_FOUND while generating migration files

```ts import type { Config } from 'drizzle-kit'; export default { schema: './lib/db/schema/*',...

Typescript error with custom column type

The select rules throws a TS error: "Expected 0 arguments, but got 1.ts(2554)" What am I doing wrong?...

Infer TS types with `sql` operator and `db.execute`

``ts const db = drizzle(connection); export async function getTodos() { const result = await db.execute<Todo>(sqlselect * from ${todo}`); return result.rows;...