Drizzle Team

DT

Drizzle Team

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

Join

Cannot push postgres

I am initiating the db schema useing drizzlekit, but for some reason I can only push once and the second time it throws an error this is me running "pnpm drizzle-kit push" for the first time ```sh root@f2771f2cc095:/app# pnpm drizzle-kit push...

Help with nested query

Hey everyone, I have the following query and it works as expected. ```javascript const companies = await db.query.Companies.findMany({...

Drizzle Error - Drizzle Kit - Integer

Received integer which cannot be safely represented as a JavaScript number
Received integer which cannot be safely represented as a JavaScript number
Bug report is attached...

drizzle-kit push connection cleanup

How do I run a cleanup script after drizzle-kit push, such as to kill database connections? Otherwise I noticed that drizzle-kit leaves connections open.

PlanetScale drizzle-kit push: Cannot drop index: needed in a foreign key constraint

Whenever I run drizzle-kit push against PlanetScale, drizzle drops and recreates primary key constraints, foreign key constraints, unique constraints etc. and keeps running into issues doing so. I've created a minimal example to illustrate the issue. In this example, the first drizzle-kit push goes through, all subsequent pushes throw an error without even changing the schema at all. `` DROP INDEX unique_name ON table1; ALTER TABLE table1 ADD CONSTRAINT unique_name UNIQUE(table2_id,name`);...

Maximum call stack for transactions

I've been trying to do a transaction over 100k rows (works at 10k) but I've been getting an error for stack size. How do I handle bigger transactions? ```bash ✗ Transaction failed. 13 | } 14 | function mergeQueries(queries) {...

Storing Images

Hi everyone, I just want to know what is the best way to store images according to these info about the system I'm building. - a user needs to have a profile picture. - I need to store a number of images for each user. - a user can create a post, and the post may have an image. - The hero section of the app may have a dynamic image that the admin can change....

Database connections do not close using RDS Serverless v2 and Data API

I am using Drizzle with a RDS Data API connection to a Serverless V2 PostgreSQL cluster. I've now started consuming some events and a particular heavy influx of events caused a few hundred Lambda function to be spun up and connecting to the database. However, even after they are all done, the RDS resource is still unavailable since it still sees all those database connections as open. The only solution I had was stopping and starting the cluster again. In a second test, I explicitly close the the RdsDataClient, but no cigar. Any tips on how I can get those connection properly closed?...
No description

Type Error on Drizzle orm comparison helpers like eq, and

Sample Code: ```ts const isAlreadyInvited = await db .select().from(InvitationTable) .where(and(eq(InvitationTable.email, singleEmail), eq(InvitationTable.organizationId, organizationId)))...
No description

query data question

I built an api in localhost:3000 where i have my drizzle schema and it is attached as an image here. I am trying to query on a react native app that i created by doing something like this {appointment.facility.address} since i have address stored as an attribute in the facilities shcema. It doesnt work when i query this way and in fact when I use Postman to analyze the json response i notice that in the only the name appears after the facility attribute within the appointment json data. is there a way i can modify this so that i can expose all of the data as an object in the facility attribute so that i can access that data and query it on the front end of my app. for now only the name displays and i want to grab the full address. example is attached as well. i would like to do this for patient too which is the same issue. thanks in advance!...
No description

Can't run drizzle studio

Hey I'm using the t4 starter monorepo and am trying to run drizzle studio however its not working. I get this error: Error: Cannot find module '@drizzle-team/studio/server' These are the terminal logs: bun studio $ cd packages/api && bun studio...

Drizzle client nested schemas

Is there a way to nest schemas within the Drizzle Queries? I have my schemas multiple files in sub directories, and I export them in groups. ```ts export * as paths from './schema/paths'; export * as reports from './schema/reports'; export * as auth from './schema/auth';...

Error handling in drizzle - best practices and future improvement

What are the best practices in error handling (see question)? Does drizzle throw anything else than postgres errors a la https://www.postgresql.org/docs/current/errcodes-appendix.html ?

Filter included relations

I am currently using the following query to retrieve all undeleted appBundles from my database: ```js const selectedAppBundles = await db.query.appBundles.findMany({ where: (appBundles, { isNull }) => isNull(appBundles.deletedAt),...

Looking for suggestions

I feel like I had to jump through way too many hoops to do this and was wondering if anyone wants to point out any potential improvements. For starters, I kept getting errors about an ambiguous date column, which isn't that bad considering the fix was to just rename the column in date_series_query to date_series_date. Try changing it back to date and you'll see what I mean. But also look at how I'm having to use concat because Postgres otherwise complained about not being able to tell what type the parameters were. I feel like there's a lot that can be improved here and I'm just looking for suggestions. ```ts xport async function dailyTotals(input: DailyTotalsInput) { const year = db .select({ year: irrigationYear.year })...

how to close underlying connection pool being used by drizzle?

hello all, in my test cases i have those before and after hooks: ```...

ZOD - how to createUpdateSchema?

What is the current workaround or alternative for the createUpdateSchema, similar to the createSelectSchema & createInsertSchema?

help with relations

I'm trying to do the query this way and it gives me this error im using hono and D1 ```js import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; import { cargoGiver } from "./cargoGiver.schema"; ...
No description

Insert returning: partial return not working

After inserting, I'm attempting to return the generated uuid to ensure that it worked, but when I do the following, I'm getting and error saying: Expected 0 arguments, but got 1.ts(2554). In the schema, the id field is a uuid and does have the defaultRandom added to it. Here's my insert; ```ts const [{ id }] = await this.db...