Drizzle Team

DT

Drizzle Team

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

Join

getPost() / getPosts() / ... what's your opinion? + any TS magician here :) ?

Hello! I was thinking of creating functions which will execute my queries, instead of putting all queries in my components. With that in place, I would be able to switch between Drizzle with any other query build / orm if I would like. To put it simply: ```ts // lib/fetchers/post.ts...

What work is required to support ClickHouse?

I'm a big fan of Drizzle. I'm using Clickhouse on tons of projects, it's one of the best if not the best database for high analytical workload across speed, efficiency, easy of use... They have a Node.js driver that's typed but no schema typing....

push:pg not creating table schema (pgSchema)

Running a local Supabase instance, regular tables and all that work as expected. Just now trying to move things around into table schemas. I've got the following schema.ts...

Drizzle JOIN vs relations

Seems like both Join and relations are equally capable when query data that have relationships. I'd assume that if one is already using Drizzle relations (with with field), then one wouldn't need to use .join(), and vice versa. Is there a reason one should use JOIN vs. relations, or is it personal preference?...

update not working

```ts export async function PATCH(request: NextRequest) { const body = (await request.json()) as Partial< Omit<Profile, "uuid" | "stripeId"> >;...

How do I infer type of pgEnum

How can I infer the type of a pgEnum? ```ts export const roleEnum = pgEnum('role', ['A', 'B', 'C', 'D', 'E']) ...

Is drizzle-kit supposed to include existings table in the migration file?

is drizzle-kit supposed to include an existing table in the migration file (the sql file)? For context, I’m using keycloak for authentication. The tables created by keycloak are on the same database as those created by my BE app. I want to query the keycloak tables using Drizzle so I use the introspect feature to generate the schema. I notice that when I generate migration file, the file includes the sql for the keycloak tables. I don’t think it’s supposed to do that because the keycloak tables...
No description

MySQL Relational CRUD

I am the own of issue #1395, it was closed but i don't know way to follow this suggestion: MySql doesn't support returning() you have to do it in a migration and send 2 different queries. Please create a help post in discord or a question in a discussion if you need further help.

Join does not work?

Hello, I nead some help with drizzle d1. I wrote something like this: ```ts const versionAlias = alias(schema.app_versions, 'version') const secondVersionAlias = alias(schema.app_versions, 'secondVersion') ...
No description

net::ERR_NAME_NOT_RESOLVED showing multiple times on the console

Hello, I'm trying to do simple database access using drizzle orm. The data got fetched, but my console has been showing a lot of the error index.js: POST https://undefined/psdb.v1alpha1.Database/Execute net::ERR_NAME_NOT_RESOLVED This is the code that I use to fetch my data. ```js export default async function getCustomers() {...
Solution:
1. Keep page as server component. fetch the data on this page. 2. make the modal accept the data as a prop from the page. this will come in when the promise resolves. 3. when the user opens the modal which is actually a client component, the data will be in there. IF you need the data to be populated based on actions from within the modal, you can do so via server actions. if you only need the data populated via initial page load, then the above is no problems....

Where should I start?

I’m considering using Drizzle on an existing project, but I would like to start with a simple, greenfield project to try it out. In the docs, should I start in the Manage Schema section or Get Started section? In Get Started, how does the migrate function work exactly in the PostgresJS example? For trial purposes, I just want to create a new database....

Is it possible to run migrations with the "neon" driver?

It's not quite clear from the documentation, and the driver package doesn't export any migrate function, and I wonder if it is possible. If it is, would love for an explanation for how, or a code example, if it isn't possible, do I need to download the node pg driver as well just for the migrations, and will it work with neon? Thanks!...

How to add external data in select

I want to add external data in select, but it only works with sql. ```ts this.drizzle.get({ from: users, select: {...

how do I store list of string in my pg table

I want to store a list of user ids in my table with currently I am doing this editors:text("editors").array().references(() => users.id, { onDelete: "cascade",}), which is giving me this error error: foreign key constraint "youtube_channel_editors_user_id_fk" cannot be implemented Detailed error => detail: 'Key columns "editors" and "id" are of incompatible types: text[] and text.', where: 'SQL statement "ALTER TABLE "youtube_channel" ADD CONSTRAINT "youtube_channel_editors_user_id_fk" FOREIGN KEY ("editors") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action"\n' + 'PL/pgSQL function inline_code_block line 2 at SQL statement'...

LibsqlError: SQLITE_ERROR: no such function: SQRT

Hi I'm trying to implement an SQLite command in libsql with the help of drizzle. I'm getting error SQRT function not available. It seems SQLITE doesn't come with the functions by default. Is this the case with libSQL too? If so how can I get it working 💆🏾‍♂️ ...

Error in SQL syntax when pushing schema

Hello, I'm trying to push my database schema to planetscale using drizzle-kit push:mysql , but I got the error below after confirming the execution. Can someone point out for me what did i do wrong?
Error: target: admin-dashboard.-.primary: vttablet: rpc error: code = InvalidArgument desc = You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
Error: target: admin-dashboard.-.primary: vttablet: rpc error: code = InvalidArgument desc = You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
this is my schema...
Solution:
i decided to not generate the uuid from the schema, remove the default value from the ID, and generate the ID when i'm calling the function. Thank you

Migration issue with PostgresSQL

I'm trying to migrate ```ts export const postLikeTable = pgTable( "post_like",...

introspect:pg generates wrong default values

Hi, I'm using introspect:pg on a keycloak schema and notice that it fails to generate default values with cast expression.
No description

managing with geom types in postgis

Hey all I work in geospatial a lot and typically help clients work with managing geospatial data on postgis databases. I know that drizzle does not support geometry at this point, but is the geom type in the drizzle schema on the roadmap for you all?...

Migration not pushing new columns to database.

When I generate a migration and run the migration script, new columns don't get pushed to the db but when I change a column type for example, and run the script, the changes get applied. This is my migration script: ``` const postgres = require('postgres')...