Drizzle Team

DT

Drizzle Team

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

Join

Svelte and Drizzle and types?

Using Drizzle and NextJS, Drizzle provides types based on the schema. Using Drizzle with Svelte, all JS functionality works but none of the Drizzle provided types work. Instead, all auto types are: "any". Any thoughts? For example, using this schema.ts in NextJS...

Connecting to Neon through Drizzle via Cloud Function

Hi there! I have a nextjs app that is hooked up to neon via drizzle. I want to use some cloud functions to do some additional data transfer into the DB. 1. Does anyone have any advice on how to set up a cloud function with Drizzle? 2. How would you go about sharing the schema between the cloud function and the next app? I'm thinking I'll need to set up some sort of monorepo like turborepo but I don't know what the deal is with putting a google cloud function in a turborepo. ...

updatedAt timestamp update on DB row update

Whats the best way to update Postgres values for updatedAt --- I'm assuming there's a drizzle helper ? Can't find anything

Issue with diverging responses via RDS Wrapper on rawSQL query.

We've recently noticed that we're getting the raw response from RDS Aurora when doing a raw query. The issue seems to be known for some months already, but due to that our team is starting considering moving away from Drizzle. Is there any way we can assist with resolving this issue in some capacity? https://github.com/drizzle-team/drizzle-orm/issues/578...

Conditional findFirst

Is it possible to conditionally use findFirst, rather than having to chain the underlying model. E.g. ```const result = await db.query.users.findMany({...

Relational Queries: How to query based on the value of a joined table?

I have a table posts, where each post has a uid. I use relational queries to perform a join of the user into the post. Now I want to write a where(..) clause which checks whether the user.public field is set to true. However, the where clause does not allow accessing values of the user but only that of posts. How can I accomplish this? ```ts const res = await db.query.postsTable.findMany({ with: {...

Invert a boolean easily?

In SQL you can do
UPDATE my_table SET is_active = NOT is_active;
UPDATE my_table SET is_active = NOT is_active;
...

Cascade onDelete when not using FK relations

Is there a way to add a cascade on delete when declaring relations without FK ? For planetscale for example ?

Error following push

SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_resume Not sure what to do about this. Any thoughts?...

SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None"

Full error:
Error: SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None": syntax error at (1, 50)
Error: SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None": syntax error at (1, 50)
...

Binary typing for Mysql & typescript

hey hopefully quick question, I have a mysql column of type binary(32), but the type coertion seems to only be accepting strings ``` // type definition signingKey: binary('signing_key', { length: 32 })...

Db race condition

Is there any tool with drizzle that can help with handling race conditions?

Setting up Drizzle with Supabase in Next.js App Router

Hey Drizzle Team, absolutely love what you are building, but i run into a few problems setting it up. I am using Next.js App router and Supabase. This is my current setup: drizzle.config.ts ```...

Select filters for n tables on relational queries

Let's just use the schema from the docs: Users has many Posts This would give me User 1 with all of their posts: `const res = await db.query.users.findMany({ where: eq(users.id, 1), with: {...

Querying Best Practices?

Just want to discuss query best practices. ```ts const userAccount = await db.query.accounts.findFirst({ where: eq(accounts.id, userId), with: {...

Using the drizzle object mapping API directly in combination with raw queries

If I were to use the raw query interfaces or even use the underlying database driver to query the database directly, is it possible to use Drizzle to handle mapping of rows to the drizzle schema? I understand it would have it's limitations but I'm really looking to leverage all the custom types and to/from driver translations I have

whats the difference.

Whats the difference of using references like this: ``` export const profileInfo = pgTable('profile_info', { id: serial('id').primaryKey(), userId: integer("user_id").references(() => users.id),...

There are multiple relations between "places" and "medias". Please specify relation name

Hello guys, could someone help me? I'm getting the following error: Error: There are multiple relations between "places" and "medias". Please specify relation name...

Count of one-to-many relation in query

Migrating from Prisma - I had something like the following: ``` export async function getAllOrganizations() { return db.organization.findMany({...

onDelete cascade, Error: VT10001: foreign key constraints are not allowed

Trying to add onDelete cascade and db push produces this error: foreign key constraints are not allowed ```...