Drizzle Team

DT

Drizzle Team

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

Join

[Relational Queries] Nullable one-to-one relationship

Hey y'all. I'm using the relational queries feature and have a one-to-one relationship between these two tables. ```ts export const teamsT = mysqlTable("Teams", {...

union or union all in drizzle orm?

SELECT 'meal' as "type" ,count(*) from meal where user_id=''
UNION ALL
SELECT 'deposit' as "type" ,count(*) from deposit where user_id=''
SELECT 'meal' as "type" ,count(*) from meal where user_id=''
UNION ALL
SELECT 'deposit' as "type" ,count(*) from deposit where user_id=''
...

Can't import as ESM from drizzle-orm/pg-core

Can't import as ESM from drizzle-orm/pg-core in express app

Transaction rollback error catching

I'm using drizzle with TRPC and want my api to give detailed reasons for a rollback. However tx.rollback() throws a TransactionRollbackError, which means the TRPC error is never thrown (i think). This means the client sees an error with message "Rollback", which isn't super descriptive. ```ts await db.transaction(async (tx) => { ...some logic...

PostgreSQL RQB truncation

I have a fairly nested query using the RQB and I'm running into issues where PostgreSQL truncates the identifiers used to 64 characters (as it normally does). In wondering if it makes sense/if there is a way to make the identifiers used in the RQB always fit into the 64 character limit because the truncation results in duplicate identifiers and makes the query fail. I am happy to send an example schema/error if that makes anything easier.

Drizzle Count # of Records

What would be the best way to count records in drizzle? Thanks!

Spatial Query in Drizzle using MySQL

I'm not able to find an example of how to create a Spatial Index as explained in this tutorial. https://www.endpointdev.com/blog/2021/03/spatial-queries-with-mysql/ Can I please get some help with how to do the following in Drizzle ORM?...

drizzle-orm doesn't compile

I've just created a blank typescript project for nodeJs and installed the library as specified in Drizzle doc. In the index.ts file of the project, I have the following code: ``` import { integer, pgTable, text } from 'drizzle-orm/pg-core';...

drizzle migration on nextjs

I am getting this error while using drizzle migration as show in the documentations. I have already set my compiletarget to es2017 and enabled topLevelAwait feature but still giving this error NB: everything works if I comment out the migration code on my drizzle db connextion setup...

findmany doesn't easily allow gte or lte?

When looking at the typescript definition of the operators in the findmany where clause I see: ``` declare const operators: { sql: typeof sql;...

How to set a default timestamp_ms for sqlite

How do I make a default timestamp_ms? ```createdAt: integer("createdAt", { mode: "timestamp_ms", })...

Migrations not being applied (drizzle-orm/node-postgres/migrator)

im kind of struggling with migrations... i have the following migration index.ts which i run whenever i generate a new migration ```ts import { drizzle } from "drizzle-orm/node-postgres"; import { migrate } from "drizzle-orm/node-postgres/migrator"; import pg from "pg";...

Delete limit

Hi, how do I delete just 1 row from a table?
// Example:
db.delete(dogs).where(eq(dogs.breed, 'husky')).limit(1)
// Example:
db.delete(dogs).where(eq(dogs.breed, 'husky')).limit(1)
...

Many to many - Planetscale

Anyone here has an example of declaring many to many relationship when using Planetscale? https://orm.drizzle.team/docs/rqb#many-to-many When using Planetscale this section doesn't work at all...

Inserting with Relation

Hi, What is the way of inserting a new record with a relationship in Drizzle. I understand that Prisma abstracts this away as if you are inserting everything as once but under the hood it breaks it up into multiple queries. Is there anything like this in drizzle?...

sql escaping on where

Trying to do the following:
where: sql`unaccent(${users.fullName}) ILIKE unaccent('%${input.query}%')`,
where: sql`unaccent(${users.fullName}) ILIKE unaccent('%${input.query}%')`,
...

Broken typescript in select

Whatever I put inside the select function. it will generate this typescript error: I am using the lastest ts- and drizzle versions....

Passing SQL functions to insert

Is there any way to pass a SQL function like gen_random_uuid() to the insert function, for a specific (non-primary ID) column? Something like concat('foo_', gen_random_uuid()) for example.

Drizzle-kit database push connection error

When trying to run drizzle-kit push:mysql to push my schema to Planetscale, I get the following error. Am I missing something? ```sh drizzle-kit push:mysql...