Drizzle Team

DT

Drizzle Team

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

Join
CGClancy Gilroy5/2/2024

MySql 5.7

Hello! I've been trying to get this going for a few days now. I've been trying to query data with relationships in mysql 5.7 using drizzle. What I know so far using mysql2 driver. - Normal mode doesn't work because lateral joins are not supported in mysql 5.7....
Nnr77515/2/2024

( sql question ) How do you join full tables with select columns from other table?

Hi everyone. I'm new to Drizzle. I have this TypeScript function: ```typescript export const fetchAllServicesWithProfiles = async () => {...
Solution:
select({id: services.id, …}).from(…).innerJoin(…)
Ssmiley5/2/2024

Cannot migrate/push after adding column to sqlite table

I'm new to Drizzle, so I assume I'm just doing things wrong. I have a sqlite db with a bunch of tables. If I add a single integer column to a table, then try to drizzle-kit push:sqlite I get the following error : ```
drizzle-kit push:sqlite...
Hhunt5/2/2024

Help building queries based on multiple conditions from an array of objects

Hello, I'm having trouble formulating a query that will match rows to multiple conditions at the same time. Suppose I have an array of objects like : ```...
LLloyd5/2/2024

Postgres.js type error string/date

I'm running the following where clause in a select query: ``` .where( and(...
Xxxxxx5/2/2024

add a prefix to UUID?

I am wondering if there is a functionality where I can add a custom prefix the uuid's. These uuids would be used as a pirmary key in my case. The end result would be something like this: product_9B4F49D6F35C49FEA0dCC579A8ED4755...
EEntsllor5/2/2024

[BUG?] Handling Postgresql schemas when using enums

"drizzle-orm": "^0.30.10" Hello. I have a simple table with a status column ```ts export const BaseSchema = pgSchema(settings.DB_SCHEMA_NAME); // DB_SCHEMA_NAME=my_schema export const statusEnum = BaseSchema.enum("version_status", values);...
Hharshcut5/2/2024

Help needed for Nested Query

For this example, I have 4 tables - user, podcast, episodes, and bookmarks. - bookmarks table has two columns - userId and episodeId - each podcast can have multiple episodeIds, each episode can have only one podcastId (one to many) - each user can bookmark multiple episodeIds, each episode can be bookmarked by multiple userIds (many to many) ...
Bbigman805/1/2024

Typescript performance in larger codebases?

Hey, I've been using drizzle with small projects, but now I'm thinking of migrating a larger codebase to drizzle. This codebase connects to a database with over 500 tables and consists of over 300k lines of code, most of which is SQL queries made with Knex. However, I'm a little concerned about typescript performance degrading at that scale. I know a common recommendation is to break up the code into smaller pieces, but unfortunately that won't be possible right now. I started incorporating Kysely into this codebase, but type checking and autocomplete became much slower. Looking at the way drizzle works I'm hoping that it could put less strain on the type checker and be more viable. Can anyone with experience using drizzle at that scale let me know how the typescript experience and overall type-checking performance is for them?...
DDawson5/1/2024

multiple dbs, multiple drizzle client, not registering as multiple dbs

Hey all, anyone know why apiDb shows up as not working? Originally when I had keys schema imported under apiDb, it worked perfectly fine. db and its table works fine. Generated using t3 index.ts: https://paste.learnspigot.com/dicuhehiri.typescript api-schema.ts: https://paste.learnspigot.com/guqayuviwe.php schema.ts: https://paste.learnspigot.com/enufuvujuq.php...
KKeith5/1/2024

Setting triggers with drizzle

Hey, good day guys. I'm a web developer who recently picked up mysql and drizzle. Going through the drizzle docs now and I was wondering if there was a way I could set stored procedures and triggers in my sql database using drizzle?
PCPradip Chaudhary5/1/2024

Multiple Where Clauses

I need to filter my data based on various filters but only if they are not null. How can I do this, so far I have tried the following ways. I have also tried to use $dynamic() in the query. ```ts const query = db .select({ id: emails.id,...
SSpeilegg5/1/2024

Enum as primary key for roles (sqlite)

I'm pretty new to Drizzle and database schemas in general so bear with me if this is stupid. I'm creating a crud application with some users with a role table. The roles are quite defined so I thought I can use a enum with the role "slug" as the ID: ```typescript...
No description
DDellgenius5/1/2024

How can I get a better structured response when querying a table (many to many)?

Hi, I am new to sql. This might be obvious, but I'm not sure how to go about this. Below is a simplified example of what I hope to achieve. I have three tables: orders, order_lines, and items. order_lines is a junction table. Here's how I'm currently fetching the data: ```typescript...
Ppatwoz4/30/2024

sql where column md5

Hey, how can I achieve the following statement in drizzle? ```sql -- mysql ...
Ccragcatto4/30/2024

Error on Query Filter: Types of property 'table' are incompatible.

I'm currently trying to filter a query as explained in on the docs, but I'm getting an error an error that I assume is caused by incompatibility with MySqlColumn and Column<ColumnBaseConfig<ColumnDataType, string>, object, object>. Maybe I am missing something but I would appreaciate some help.
No description
Ppedro4/30/2024

How to do Computed Fields / Manipulate data at Query Level?

I'm looking for something like this, on prisma we can validate fields when querying the model. I couldn't find how to do this using drizzle. I need to use JS because it's necessary to decrypt the string
No description
BVEBaron Von Enablestein4/30/2024

pgEnum conversion not working as expected

I have the following pgEnum defined:
export const ApprovalRequestTypePgEnum = pgEnum('approval_request_type', ['CREDIT_NOTE']);
export const ApprovalRequestTypePgEnum = pgEnum('approval_request_type', ['CREDIT_NOTE']);
...
GEPGary, el Pingüino Artefacto4/30/2024

Filtering a jsonb with the shape Array<{id:string,name:string}>

Hi. I have a query that returns all the posts with it's categories like this, ```typescript type Posts = { id: string title: string...