Drizzle Team

DT

Drizzle Team

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

Join

Dont throw error if the relations is not correct

const posts = await db.query.posts.findMany({ with: { comments: true, }, });...

tsc fails to build due to errors

When I run tsc to compile the project to javascript, I am getting the following error: ``` Found 4 errors in 2 files. Errors Files...

trying out neon.tech should i use "Pooled Connection"?

the title says it all, i'm going to try moving to Neon database (postgres) but i'm not sure if i should use a pooled connection or not. Thank you...

Discrepancies Between Raw SQL Queries and ORM Operations: Why Might They Behave Differently?

What could be the potential reasons for a query executed using the execute method to function correctly, while the same query using an ORM approach (i.e., db.insert().values(), etc.) doesn't produce the expected results or doesn't work properly? First screenshot doesn't work, while second one works properly

I need help generating a query for a schema

Hi guys I have the following schema ```ts export const companies = pgTable('company', { id:serial('id' as string).primaryKey(), name:varchar('name' as string).notNull(),...

Best way to omit a field (e.g. password) after findMany from schema?

Let's say we have the following: ```typescript export const User = pgTable( 'user', {...

How to implement interface for table?

Say I have an interface of User ``` interface User { id: string,...

onDuplicateKeyUpdate

Is this the correct way to use this method? Can't find documentation ```db .insert(schema.item) .values({...

drizzle weird error message on database operation

I am getting this weird error when doing database operation

permission denied on insert

I have a drizzle user with full permissions set but I am getting permission denied errors, I have rls enabled

How can I reference the RelationalQueryBuilder and RelationalQuery types?

These types are currently not exported from the library AFAIK. I would like to reference these types to build a generic query builder for our internal use. How can I get to them?

Dropping unique constraint cant push to db

I have this key here nftCollectionIdKey: unique("Pool_nftCollectionId_key").on( table.nftCollectionAddress ), ...

I'm getting circular dependency problems because each table relation is declared from the table file

Is there a better way to declare relations ? What I ended up doing was declaring all my relations in a separate file "relations.ts"....

How do I import a type?

This might be something I'm just totally overlooking, but I'm used to prisma where you can just import any schema you've defined as a type. For example, if I have a table posts, I'd expecect to be able to import a Post type to be used in one of my child components. Is this possible with Drizzle? Or have you all found it to be unnecessary...

When pushing migrations to Supabase, it skips saying the schema "drizzle" already exists.

When I update my schema and try to push the migration to Supabase, I get the following error. How can I move forward with pushing it as opposed to having it skip? I guess part of the issue is I don't understand how migrations really work so not sure what this error is telling me is wrong. In my database, I already have 2 entries in a table called __drizzle_migrations under the drizzle schema that was auto-created by drizzle-kit when migrating the first few times ```js...

0 tables fetched when introspecting a postgres database

I granted all permissions to a drizzle user like this
GRANT ALL PRIVILEGES ON SCHEMA public TO prisma;
GRANT ALL PRIVILEGES ON SCHEMA public TO prisma;
But when I try to introspect with this connection string...

PostgreSQL migration issue in AWS RDS with Drizzle ORM: 'no pg_hba.conf entry for host' error

I've been using drizzle for a new project over the past few weeks, and it has provided a great developer experience. Now, it's time to bring the app to production. However, I'm currently facing an issue with the migrations. The app is deployed in AWS ECS and connects to a PostgreSQL database in AWS RDS. I have provided the necessary IAM policies in the ECS task role to access the RDS instance. The connection is established but after that when I execute the migrate function, I'm encountering an error that I didn't experience while running locally. ```...

Date condition on where function

Hello everyone, so I have this schema of accounts and I want to get all the data from the current date ``` export const accounts = mysqlTable("account", { ......

ReferenceError: Cannot access 'addon' before initialization

This is one of the files in ./schema/ ```ts import { integer, primaryKey,...

DISTINCT ON syntax error with multiple columns in select

Hi! Thought I'd bring up this issue I opened here: https://github.com/drizzle-team/drizzle-orm/issues/963 Let me know if we think this is a valid issue or just a pure user error. Happy to close it if I'm doing anything wrong!...