Drizzle Team

DT

Drizzle Team

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

Join

Using cloudflare pages postgres and lucia

Hey all im running into so many issues trying to get this setup, has anyone done this before, i have tried to use createClient, sql and createPool from @vercel/postgres but i cant get it working, does anyone have an example of how do this? i want to use a direct connection to my postgres db...

Is drizzle safe to use in production?

I would like to use drizzle(orm and kit) on new projects. I get confronted with arguments like, is it battle tested, or drizzle is still in beta, or it's new and there might be some hidden bugs that would lead to data loss, like accidentally dropping some columns, tables, etc... I think that time will battle test drizzle,...

Chaining/combining $dynamic query functions

Hi everyone - I'm trying to take advantage of the new dynamic query building feature to simplify the way I query my db for displaying data in a table. I've already implemented a nice helper function to add ORDER BY to a query, e.g: `const result = await withOrderBy(qb, {...

Mapping/Renaming column names for MariaDB when using RETURNING *

I know that RETURNING is not supported for MySQL but MariaDB supports it, so I have tried to "hack" it somehow using custom raw query. I would like to ask: 1) Is it possible to use internal mapper for column names from the schema definition, in order to avoid manually "renaming" them? 2) Is there a better way to write this? My code looks like this:...

Timestamp error when pushing Postgress change with drizzle-kit

Hey, I am always getting the message to truncate databse table timestamp() is used (see CLI screenshot). This is quite bad as the dev database s always getting reset. Migrations work fine thought. Any ides why it is always messing up the timestamp?
No description

db.update fails with undefined 'relation.referencedTable'

Running into a strange undefined error when running db.update on the lone table in my SQLite database. ```javascript app.put("/todos/:id", async (c) => { const { id } = c.req.param();...
No description

Help with query, how to use parent value in where condition ?

Hey everyone, is there any way to pass a value from the parent, which is widgets in this example to a where condition in a left join ? ```ts await db.query.widgets.findFirst({ where: eq(widgets.code, 'widget1'),...

One to Many Self Relations...

I have been trying to establish a self relation in my schema and have not find anything valuable yet. What I want is this: A user will have one of two roles "EDITORS"/"ADMIN". An admin user will have editors associated with them. An Editor user will have only one Admin to them....
No description

This is a question about type inference.

hello. Can you tell me why the type of the query result is not inferred?
No description

Omit fields on "$inferSelect"?

Let's say I have a table with 5 columns, I want to do type TableType = typeof theTable.$inferSelect; but omit some fields. How do I do that?...

Full-text search on jsonb column

Hey, I was experimenting with full-text search and drizzle. I saw in the docs an example for full-text search https://orm.drizzle.team/docs/sql, but this seems to only work with text columns. How would I convert the where statement to make it work with jsonb? @Angelelz

Connecting Remote Drizzle Kit Studio to a Server

Since the studio moved to a local HTTPS address, I can't access it on my Ubuntu server. Previously, I used a port to access Kit Studio, but now it's a local address. What should I do?

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]

I'm getting the following error using node / nodemon / ts-node. Just started happening, never had this issue before: ``` Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './index' is not defined by "exports" in /Users/bob/Public/Code/api_node/node_modules/drizzle-orm/package.json at new NodeError (node:internal/errors:387:5)...

Define a index with condition

I'm trying to define index with where but migrations generated in index without where condition. Is there an ETA of when this feature will be supported?

Cloudflare D1 TypeError: Cannot read properties of undefined (reading 'prepare')

Trying to query a D1 sqlite database and seem to be running into this error, sounds like the parser is tripping up on itself I have been debugging for a few hours and can't seem to figure out what is wrong has anyone seen this before?

Error Parse BigInt

When I've a blob big int column and I try to select or returning the data, my bun execution is terminated because the parsing is crashed. https://github.com/emersonlaurentino/drizzle-bigint...

Having trouble writing my sql statement in drizzle. Want to join two variables

I am trying to execute this sql statement with drizzle ``` SELECT er.*, e1.name AS entity_one_name, e2.name AS entity_two_name FROM "public"."relation" er JOIN "public"."entity" e1 ON er."entityOneId" = e1.id...

How to implement Row Level Security in Postgres?

In my chat app, I have chats and messages. There are multiple messages in each chat. I'm trying to prevent user1 from editing user2's messages. ChatGPT suggests row-level security like the following ```sql...

Get the result raw sql

I love drizzle and everything it does, but it cannot integration with a certain tool I'm using in a comfortable way.. I wanted to know if it's possible to create a query or whatever and reach the inner final sql as raw string?

Set onDelete while using foreignKey function

Hi. I'm trying to set onDelete action with new "custom name" foreign key config. The problem is that I can not find such option. While FK defined through references it's possible as a second argument. Any ideas?
No description