Drizzle Team

DT

Drizzle Team

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

Join

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

Upsert Multiple using EXCLUDED

hey there - I want to upsert multiple values and overwrite certain fields in case of conflicts. using plain SQL it'd be something like this: ```sql insert into "surveil" ("id", "last_seen", "name") values...

defineConfig, Cannot find module 'drizzle-kit/utils'

when using the new way to define drizzle config get error Cannot find module 'drizzle-kit/utils' or its corresponding type declarations.ts(2307) using drizzle-orm: 0.29.0 drizzle-kit: 0.20.1...
No description

SQLite composite primary key error.

I'm trying to add a composite primary key for the following table but I'm getting a type error. I've referenced the docs and this looks to be the correct syntax so I'm just a little confused. https://orm.drizzle.team/docs/indexes-constraints#composite-primary-key
"drizzle-orm": "^0.28.6",
"drizzle-orm": "^0.28.6",
...

WITH RECURSIVE support… or suggestions for how to approach?

Hi. I'm absolutely loving Drizzle after a little while in both Prisma and TypeORM and 15 years of Rails + ActiveRecord. I have the following query that uses WITH RECURSIVE. I'd love to use Drizzle's query builder but I cant see how I might tackle that. Am I right in thinking that this is going to need to be supported in the select helper https://orm.drizzle.team/docs/select#with-clause ? ...

How to implement a 'check' constraint

I'd like to implement a 'check' constraint that implements these psql table constraints below. What is the best way to add this constraint in native SQL alongside my drizzle table definitions if it is not yet supported as a native Drizzle piece of functionality? -- User Table CREATE TABLE "User" ( UserID UUID DEFAULT uuid_generate_v4() PRIMARY KEY,...

Add descending indexes in mySQL schema

I do not find how to add a descending index from a schema in mySQL. I know I could always execute the following line manually:
ALTER TABLE tablename ADD index col_desc_idx(col desc);
ALTER TABLE tablename ADD index col_desc_idx(col desc);
But I'd really like to be able to include it in the drizzle-kit push command because I know I will forget at some point otherwise....