Drizzle Team

DT

Drizzle Team

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

Join

Cant drizzle-kit pull with next.js from supabase postgres

Hello, trying to learn drizzle by connecting it to an existing supabase project (postgres), and need to pull the DB schemas into drizzle. My drizzle.config.ts: ``` import { config } from "dotenv";...

Trying to use deno...

So i'm trying to generate migrations using drizzle-kit with deno? ```bash deno run -A npm:drizzle-kit generate [22:31:46] Failed to find Response internal state key...

Cannot use pgEnum with aws aurora

Hi. I can't seem to use pgEnum with the AWS aurora adapter, as i keep getting the same error over and over. It seems weird, as intellisense doesn't say that the types are wrong at all when i am doing the update query, but pg returns an error ERROR: column "status" is of type "EmailStatus" but expression is of type text; Hint: You will need to rewrite or cast the expression.; Position: 31; SQLState: 42804 ```ts await db...

Setting Procedures and Triggers and custom SQLs

Hi. I am using drizzle with mysql in ts, I want to add functionality of procedures and trigger them after specific db calls. How to do it? and if i change something in procedure like edit/delete/add how to handle it's migration. In on case i have table and it has primary key which is autoincreement but i need to start the count from 1000, how to handle this and If I add something like this to other table after deploying my database how to handle it's migration...

mapping data inside select function

Hi. Is there no other way to map data with nested object with select() function other than array.reduce? I would like to do it using the query, not JS as the amount of data can be big and take a long time. For now I am doing this by writing a big query using sql function in execute() but then I don't get real TS support for my types and I feel uncertain about possible bugs.

db client typing

Good morning. I am using the new connect method, and working on typing. I am new to TS so still working out how to make it work. ```ts interface Client { config: Config;...

I can't connect to the DB const db = await drizzle("node-postgres", process.env.DATABASE_URL!);

I just want to connect the DB through the above command. The expected problem is that the DB is not allowed public access, so I need SSH authentication, which is not provided by drizzle orm. Is there any way? error msg Error.captureStackTrace(err) ^...
No description

Does drizzle-graphql let you filter, sort, and page?

hi! im trying to decide what to use on the server for my app, and drizzle seems great, and drizzle-graphql could be really nice. But does it let you filter, sort, and page results? Like how Hot Chocolate does for .NET

PgColumnBuilderBase and notNull()

holy mother of types ... could someone help me out here? ``` export function ref(id: AnyPgColumn): PgColumnBuilderBase { return bigint({ mode: 'number' })...

0.32.0 introduces unmentioned breaking change

```ts export const managerSettings = pgTable('ManagerSettings', { defaultSettingsProfileId: uuid('defaultSettingsProfileId') .unique() .references(() => settingsProfiles.id, {...
No description

Transaction Type

Is there a type to use for passing a transaction into a function? I would like to do something like
await db.transaction(async (tx) => insertUser(tx, form.data))
await db.transaction(async (tx) => insertUser(tx, form.data))
but the type of tx is super long and not convenient at all....

How to implement a generic/reusable function for multiple tables

I have two separate tables for article views and case views and currently have two backend endpoints to get the last viewed cases and articles: ```ts const distinctCaseViewsSubquery = db .select({...

How to connect to local sqlite database

I wanted to play around with drizzle and sqlite in a next.js project. But I can’t even create the client like it’s described in the docs: ```jsx // page.tsx import { drizzle } from "drizzle-orm/connect";...

Unclear docs on bigserial mode

Unfortunately the docs are not clear here: ``` id: bigserial('id', { mode: 'number' }).primaryKey(), questionId: bigint('question_id', { mode: 'number' })...

[SQLite] How to db:push with in-memory db?

I mean something similar to drizzle-kit push. I want to use in-memory database for unit testing with vitest....

Wrong docs on casing

The docs chat bot suggests this but that seems wrong
const db = drizzle(client, { casing: 'snake_case' })
const db = drizzle(client, { casing: 'snake_case' })
...

Updating many-to-many best practice

Hi, Im currently working on an admin dashboard for my schemas. I reached the point to where I have to update a many-to-many relation. Take for instance a User model, that can belong to different Groups. In my admin dashboard, I have a edit user form that posts the new groups that should be related to the user. How do I update this m2m relation in the most efficient way? Do I find the diffs between the old and new groups and then do a delete/insert based on the diff? Do drizzle do any of this "out of the box" with a method I dont know about?`...

Changing the Postgres serial/autoincrement behavior

In short, I don't want the serial to fill the empty gaps. I want it to always default to max(id) + 1 unless I specify the id myself. How can I achieve this with minimum jank? I've heard of generated columns, but couldn't get it all working together. I believe MySQL works like this, so I might have to switch to that....

Warning: You need to pass an instance of Client:

I'm getting this warning as described here: https://orm.drizzle.team/docs/latest-releases/drizzle-orm-v0294 Using drizzle-orm 0.31.4. But I'm already using a client instance: ```ts import { Client } from '@planetscale/database'...

$with is not taking an Insert with a return

example const chatId = db.$with("chatIdQ").as( db.insert(chats).values({ receiverId: 21,...