Drizzle Team

DT

Drizzle Team

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

Join

How to insert many rows with one-to-many relationships

I have 100+ rows I want to insert into an artists table, and at the same time insert each artist's songs into a songs table. Each song would be linked to the artist ID, but the artist ID would be generated by the query itself. Any way to accomplish this with Drizzle? Basically, I have data like this I want to insert: ```js [...

Drizzle migrations workflow with CICD and multi-dev teams

Hi! I'm looking into ORMs to use for my team in a new Node/TS project, and Drizzle has caught my attention. tldr: Is it possible to use Drizzle in a CICD pipeline to apply migrations? One thing that I don't have clarity on is how Drizzle would work in an environment where multiple devs are working on migrations concurrently. ...

Query from table with where clause NOT IN another sub query?

For ex: select * from TableA where email not in (select email from TableB); ?

how to empty a table (postgres)

What's the best way to programatically empty a database table? I'm using ``javascript const emptied = await db.execute(sqlDELETE FROM featured_salons;`)...

using in nest.js

What is the proper way to use in nest.js (or express). Should I create one single instance of db that should be exported (singleton instance), or the db should be created each time when needed? Is there somewhere a sample code when using with nest ?...

"bind message supplies 1 parameters, but prepared statement \"\" requires 0"

`` const results = await drizzleDb .select({ count: sql<number>count(*)` }) .from(calls) .where(...

POSTGRES_URL_NON_POOLING vs POOLING

I'm setting up postgres and drizzle to try to run some edge function. I'm reading these docs: https://github.com/vercel/storage/tree/main/packages/postgres If I understood correctly edge functions can't use pools so I should use the POSTGRES_URL_NON_POOLING url to connect, is that correct?...

Subquery in select

Hi, is it possible to use subquery in a select? I'd like to generate something like this ``` select "user"."name", "userAddress"."address", (select count(*) from "userLike" ul where ul."likerId" = "user".id) as "likeCount" from "user" ...

Error when running drizzle-kit generate:mysql

I have no clue what this means ```apache ...>pnpm drizzle-kit generate:mysql drizzle-kit: v0.17.1 drizzle-orm: v0.26.5...

[Postgres] prepared with inArray & placeholder

Hello there, I can't see why It ends with an error :/ ```ts...

Transactions with postgres

So, I have my authentication set up in a way that each user 'lives' in two separate tables, Users (email and password) and Customers (more personal data) This is my registration controller: ```javascript authRouter.post('/register', async (req, res) => {...

Relational queries (PlanetScale)

Hi, does drizzle-orm/mysql2 support relational queries? I am currently using PlanetScale, but I haven't been able to find any information about relational queries in the following documents: - https://orm.drizzle.team/docs/rqb...

Tx Rollback meesage

Hey! If I throw a tx.rollback(), is there a way to specify an error message beyond "Rollback" ? I have a transaction in a try/catch block and would love to specify the failed employeeID and throw a custom error message including the employeeID whos transaction failed

Sqlite insert returning typing help

Been using this lots for PG but trying now with Sqlite. I'm confused by how tog et the returned object after inserting. It's not super clear from the docs: ``` const _company = db .insert(companies)...

Drizzle-orm for Vercel, select do not take any argument?

Hi, I want to deploy to Vercel my small app made in Qwik, it seems like Vercel edge do not support Prisma so I migrated to drizzle but I'm facing an odd problem, the vercel package of drizzle expose a .select() without any argument, for example I would like to take only some columns of an entity, and more importantly I want to be able to return a COUNT of the elements, without it I would need to load the entire table 😦

Migrating from Prisma to Drizzle - What would be helpful to track for a before / after?

Heyo, I’m migrating @Answer Overflow from Prisma to Drizzle and since it’s a project in production I figured it might be nice to get some real world data from the migration. My main reasons for swapping over is to run on edge, cut my bundle size, and use the HTTP planetscale driver, and have the sql query builders. Also I like the name more From the perspective of the Drizzle devs, is this something that’d be valuable to track for a before / after to have for Drizzles’ marketing / docs / blogs or is it not really needed?...

Refetching?

Hello I just put up an app using Next 13 app directory and I decided to give Drizzle a try. Everything went great but my data (fetched in a RSC and passed into a client component) is stale. I added new rows to the db, but Drizzle does not refetch. I searched docs and couldn't find an answer. What's the best way to go about refetching periodically?

Count, Distinct, etc (postgres)

Where can I find documentation for these kinds of db operations? I'm using drizzle with postgres-js Thank you...

Query/select statement of column via sql`` for extras field

is it possible to make a normal select to another table inside a extras object in a relational query? i'm trying to do something like this: ```ts...

onConflictDoUpdate array

Hi, is it possible to upsert/update an array? ```ts await db.insert(organizations).values(organizationsResponse.organizations).onConflictDoUpdate({ target:[organizations.id], set:{...