Drizzle Team

DT

Drizzle Team

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

Join

Custom fields of db.query for many to many relationship for FE

Is it possible to just use "sizes" and "colors". Not sizes.size and colors.color? so that I dont have to change my Frontend ```...
No description

Canging the value of a primary key that is referenced by foreign keys in other tables

I want to change galleries.projectId which is in relations with files.projectId, is there a way to do this?
No description

Using drizzle with a DI container - which type to use? Getting error

I'm using the mysql driver and I am attempting to use my DI container (Inversify) to inject the drizzle db into my repository classes, but having trouble with which type to use. I'm actually getting a runtime error. I've created a db like this: export const db = drizzle(poolConnection); and my Inversify config is pretty simple: container.bind<MySql2Database>(TYPES.Database).toConstantValue(db);, and then my repository class constructor simply has a field @inject(TYPES.Database) private db: MySql2Database,. I'm pretty sure this is all a standard setup I'm not getting any Typescript errors, but the dev server fails to run with this message:...
No description

All values of query result are of type string

I I use Drizzle as query builder ``` let query = qb .select( {...

`Argument of type 'SQL<unknown>' is not assignable to parameter of type 'IndexColumn'.`

Hello I am creating a schema like this guide (https://orm.drizzle.team/learn/guides/unique-case-insensitive-email) but i get the error in the title on .on(lower(table.email)). This is my code: ```ts import { SQL, sql } from "drizzle-orm"; import {...

D1_ERROR: near \"ilike\":

Can anyone spot what I'm doing wrong? Drizzle: ``` export async function searchByFontFamilyName(db: DB, search: string) {...

Raw SQL query (`.execute()` doesn't exist)

I'm trying to run a raw SQL query for sqlite3 with the Bun driver and I'm finding that .execute() doesn't exist. Anyone got any leads? ```ts import Database from "bun:sqlite" import { drizzle } from "drizzle-orm/bun-sqlite"...

limiting json_agg

Having a bit of a skill issue limiting the amount of data returned from json_agg ```js const query = ctx.db .select({...

Custom aggregation column types

I have a custom column type with Drizzle for a monetary amount column (numeric PG type). The type is transformed into a "Big" type from a library, allowing me to do decimal-accurate math. However, in aggregations like sum, it goes back to being a string. Is there a way to write custom aggregations as well?...

Introspect poor accuracy (SQLite/Turso)

Is it just me or does introspect work pretty badly? A few examples: - Named foreign keys getting dropped....

query with one to many (postgres + foreign keys)

I have the following schema: ```ts export const accounts = pgTable("accounts", { id: serial("id").primaryKey(), address: text("address").notNull(),...

When and how to perform transactions

I’m new to the concept of transactions on SQL, and was interested in understanding if there is a way to apply every change I make to my schema as a transaction in case anything goes wrong, so it can be rolled back. Or am I thinking this wrong? When should transactions be used?

Drop DB

Is there any way to drop the entire db? im using seed data and want to reset the db before seeding.

URL_PARAM_NOT_SUPPORTED using SQLite Cloud

Hi all 👋🏼 I'm using this url sqlitecloud://g7yja3sra6.sqlite.cloud:8860?apikey=************* and when running drizzle-kit migrate I get that URL_PARAM_NOT_SUPPORTED: Unknown URL query parameter "apikey". Any ideas why this is? Isn't any query parameter allowed or something?...

How do I make .returning() return only the inserted value instead of array

Here I have createResource to insert a single record. The result from .returning is an array. I am using neon postgres db
No description

feedback on my database design (specially with relationships)

I'm designing my database, and I'm very bad at relationships, so I would like it if someone could give me feedback on how they're structured. check the diagram in details here: https://dbdiagram.io/d/buildsquare-667414d05a764b3c72fab358...
No description

Deeply nested "with" param in query is failing

I'm trying to query with deeply nested with param and getting weird error. Am I doing anything wrong or is this a bug? drizzle-orm: 0.31.2 Typescript code:...

$inferSelect and $inferInsert doesn't return table types

Hey There, Im Using Koa.js having issues with inserting as the types arent correctly referenced from the table. tsconfig.json: `{ "compilerOptions": {...
No description

Type Hinting $inferSelect

Hi Drizzle Team, I have the following tables set up with Postgres and Drizzle. There is a reviews table with an enum status field. When the status is assigned, the userId field is non-null, otherwise it's null. Is there a way to typehint reviews.$inferSelect such that it adheres to the type logic above?...