Drizzle Team

DT

Drizzle Team

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

Join

Malformed migration file

For some reason, when running migrations on the latest versions of drizzle-kit and drizzle-orm, it fails with data is malformed on most of my previous migrations' metadata: ```sh migrations/meta/0002_snapshot.json data is malformed migrations/meta/0003_snapshot.json data is malformed migrations/meta/0004_snapshot.json data is malformed...

using subquery with query builder

Hello 🙂 Please help me ) I try to use subquery with query builder, but i get a type error in eq function. How can i fix it?
No description

Multiple subquery on where condition in findMany

I wanted to know if how we could do a multiple subquery on the where condition on findMany. where: (campaign, { eq, and, exists, or }) => and( ...whereCondition,...

How to work with Cloudflare D1 on nextjs with drizzle - (Database Error: [TypeError: Cannot read pr)

src/lib/index.ts import { drizzle } from "drizzle-orm/d1"; import * as schema from "./schema"; const customConfig = {...

need help to optimise a query

[schema in first comment] I want to get an object like this: ```ts const event = { id: event.id,...

drizzle error

, params) : SQL.run(this.#handle, query, ...params); 191 | } 192 | 193 | prepare(query, params, flags) { ^...

In memory feature, drissle has?

``` import { drizzle } from 'drizzle-orm/better-sqlite3'; import Database from 'better-sqlite3'; const sqlite = new Database('sqlite.db');...

Edge Runtime + Supabase + Drizzle: Possible?

Hello all- I am attempting to move my DB from planetscale to supabase, but after swapping to postgres clients, I started getting errors from Vercel during build: "The Edge Function "404" is referencing unsupported modules". The modules in question have been postgres when using postgres.js and then pg-connection-string, pg, pgpass, and split2 for node-postgres. I assumed this meant that these clients are not compatible with the edge runtime, so I looked at how others were connecting in environments like CF Workers, and it seemed like the recommendation was to use the "@supabase/supabase-js" supabase SDK instead. However I'm not sure if its possible to wrap drizzle around this client, rather than one of the plain postgres ones. Anybody figure out how to get drizzle working with supabase from an edge serverless function? I know Neon has a serverless client but I'm trying to make use of supabase's auth tools....

$dynamic() select

Hi, I'm trying to build a graphql wrapper for my drizzle datbase and was super stoked to see the $dynamic() query builder. However, doing joins in a wrapper is possible, but I don't see a way to do partial selects with the dynamic api. https://orm.drizzle.team/docs/dynamic-query-building https://orm.drizzle.team/docs/joins#partial-select ...

New to Drizzle

Hey there, I am relatively new to drizzle and all that stuff, but I want to understand how to use it with my Skeleton UI (SvelteKit + Tailwind) App. I want to use Supabase as my db. Maybe can somebody help me try to set up a todo app or a blog or so 🙂

Multi-service, different schema in one database (postgres)

Sorry if it's duplicate, I can't find it after trying to search for a while. My use case is: I use drizzle with multiple service, every service connect to the same database instance and same database, separate by the schema. So far so good until I try to run migration, the migration script only do migrate the first schema only. But no error occurs in the command line....

How to inspect generated query?

Hi I have the following: ```typescript const _results = await this.getDBContext() .select() .from(payouts)...

auth err?

Event: checkout.session.completed PostgresError: password authentication failed for user "postgres" at ErrorResponse (file:///C:/Users/collin/Desktop/svelte/node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js:771:26) at handle (file:///C:/Users/collin/Desktop/svelte/node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js:473:6) at Socket.data (file:///C:/Users/collin/Desktop/svelte/node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js:314:9)...

Create unique slugs with $defaultFn

Hi there, Just wanted to know if it was possible to create unique slugs for every user using $defaultFn. My slugs are generated based on another field's value and must be unique. Using defaultFn, can I access the tables current values?...

Typescript errors following drizzle-kit quick start

Files and errors in comments I'm attempting to follow the drizzle-kit quick start. I am encountering 2 issues. When attempting to run index.ts with pnpm tsc src/index.ts I get typescript errors from inside the drizzle-orm library. When I attempt to run the resulting src/index.js file with node src/index.js it fails with errors....

sqlite insert results in error: "SQLite error: no such table: main.__old_push_items"

2 of my 3 table insert work fine, but my auctions table inserts do not work for some reason. When I try to insert data into my sqlite db on Turso I get the following error:
LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_items
LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_items
...

A way to use the update function with existing value in row?

How do I do the following SQL UPDATE counts SET count = count + 1 WHERE id = 1 but with drizzle orm, such as ...

group by inside relations ?

i want use groupBy inside a relations ``` const tire = await ctx.db.query.tire.findFirst({ where: (tire, { eq }) => eq(tire.id, Number(input.id)),...

Insert or Update: Error undefined is not an object (evaluating 'col.name')

Hi, I'm trying to implement Insert or Update ```ts export async function insertOrUpdateUser(user: UserInsert) { const db = await getDatabase();...

mysql2 many-to-many

Is there an example of a mysql many-to-many relationship? I haven't been able to find one and I'm getting a foreign key constraint db error similar to this post https://planetscale.com/blog/working-with-related-data-using-drizzle-and-planetscale. I've created a join table with foreign keys and relations in line with the example here https://orm.drizzle.team/docs/rqb#many-to-many. Many thanks!...