Drizzle Team

DT

Drizzle Team

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

Join

Select EXISTS

How to query boolean value if row exists or not. In pure sql it will be like this:
SELECT EXISTS(SELECT 1 FROM your_table_name WHERE id = 1 AND version = 5)
SELECT EXISTS(SELECT 1 FROM your_table_name WHERE id = 1 AND version = 5)
...

Zod schema validation from Drizzle schema

Hello i have an issue with zod creating schema from drizzle. I don't understand why my categories won't works while my customers works with the same export code feel free to ask more elements I know that it could be a zod issue but there is no one active on their server and maybe someone here can help since i had recommandation tu use zod in this discord server...

Each element of array is a foreign key

Hello, I'm trying to figure out how to create a postgres schema that will hold an array of ids property, and each element of that array is a foreign key. Is this possible with Drizzle? Here's my implementation: ```typescript...

Buffer isn't defined

I use blob mode:json for my fields and run it on Cloudflare Workers. But I get that Buffers isn't defined. As I understand blob only compatible with Node.

Is it possible to do lateral sub-query join without relational queries?

I'm trying to rewrite the same query that the relation query builder does behind the scenes but not sure if it's possible If i log the query this is what i get ```sql select "articles"."id", "articles"."title", "articles_keywords"."data" as "keywords" from "articles" left join lateral (select coalesce(json_agg(json_build_array("articles_keywords"."article_id", "articles_keywords"."keyword_value")), '[]'::json) ...

[Remunerated] Looking for help to switch my project from Prisma to DrizzleORM

Hi folks! Been building the MVP for my startup (https://CocktailAndDinner.com) using MongoDB & Prisma. Now, looking to switch to Planetscale + DrizzleORM. This can become an ongoing work, but for now I'm looking for a senior dev to mentor me....
No description

drizzle studio tables are empty

Hi, I created app using Next.js, TRPC and next-auth and I setup auth logic with Discord Provider, everything works fine except when I run drizzle studio all tables are empty even tho I can login without problems, anyone had something similar? btw I'm using sqlite...
No description

Bug on custom type inference? Maybe I'm doing something wrong.

```ts export const timez = customType< { data: Date; driverData: string;...

JSON with PostgreSQL not serializing correctly

I have define my field like this:
hostnames: jsonb("hostnames").$type<string[]>().default([]),
hostnames: jsonb("hostnames").$type<string[]>().default([]),
...

hashing password in Cloudflare Workers

Can someone help me find function to hash password and verify it that works in Cloudflare Workers

How to get the count of records? Here is my normal sql, trying to translate into drizzle

```.select({ id: comments.id, parentId: comments.parentId, // TODO countReplies: get the comment count where this id is listed as the parentId of other comments (...

Is there a way to create check constraint?

I need to have a check constraint in my schema. I know check function is currently not supported, but is there a way to hack our way into implementing it?

How to add to the database where the table has a many relationship to another table

I have a users table, which has a many relationship to to a posts table. I want to add a new user to the table, which I can do, but how do I go about adding new posts to that user? Does it add a full post object to the user? Or just an id to the new post which will be in the post table? `export const users = pgTable('users', {...

Where clauses across multiple tables in relational queries

Is is possible to specify a where condition in a relational query that includes conditions from the primary table and one or more relations? e.g. ```ts {...

Prepared queries typings lost after export in monorepo

I'm using SST and I defined my prepared queries in a separate core package to be used across functions in the functions package. The prepared queries are defined like that: ```ts // packages/core/db/preparedQueries.ts...
No description

Nodejs - Typescript Project Build

I am stuck at building typescript node project, When I run tsc I get these errors because of drizzle.

Column Unique name appears to be incorrect when spreading common fields to multiple tables

Came across this issue. Not sure if it's a big deal but i am spreading a common set of timestamp fields around to most of my tables and it looks like the unique name is incorrect. It looks like all my tables have this 'organizations_created_at_unique' naming convention on them with the unique field ```ts [ 'created_at', 'PgTimestamp', 'organizations_created_at_unique' ], [ 'updated_at', 'PgTimestamp', 'organizations_updated_at_unique' ],...
No description

Nested Relations Where has Zero Typings :confused:

Hey guys - first post so please let me know if this isn't the wrong place or I'm doing something wrong. Anyhow, I'm trying to order a simple nested relation in a query: ``` await db.query.channel.findMany({ with: {...
No description

on every `migrate()`: schema "drizzle" already exists, skipping

Hi there! I have setuped a postgres DB. Everytime I call migrate(), it works and migrates, but returns these two warnings: ```bash { severity_local: 'NOTICE',...