Drizzle Team

DT

Drizzle Team

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

Join

SelectionMap with nested objects

Hi, I'm trying to re-create the db.query({ with: {} }) but it's not working with nested objects because I don't know the type. For example: ```ts...

Type error when seeding from a .json file

This is my drizzle schema ```export const accounts = sqliteTable( "accounts", { id: text("id").primaryKey().default(uuidv4()),...

How to combine 'union' and 'orderBy'

const a = db.select({ transaction: onlineSales.transactionId }).from(onlineSales);
const b = db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales);
const result = await unionAll(a, b).orderBy( across resulting rows ??? );
const a = db.select({ transaction: onlineSales.transactionId }).from(onlineSales);
const b = db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales);
const result = await unionAll(a, b).orderBy( across resulting rows ??? );
...

Messed up installation

I am afraid that i might have messed up the installation. How to remove drizzle completely and have a fresh install?...

Normal boolean conditions

Hello, i want to achieve the following: ``` const record = await drizzle(c.env.DATABASE)...

Migrations complain about missing relations

I get the following error when running migrations:
PostgresError: relation "public.users" does not exist
PostgresError: relation "public.users" does not exist
...

Studio throws "Error: getaddrinfo ENOTFOUND base"

Hi there i just downgraded drizzle-kit to 0.21 because of this Issue: https://github.com/drizzle-team/drizzle-kit-mirror/issues/406. I am running: drizzle-kit: v0.21.4 drizzle-orm: v0.29.3...

Possible bug with nested query + reverse access

I have a pretty nested query. ``` // fails const result = await tx.query.projectinternalcost.findMany({...

https://local.drizzle.studio/

Am unable to run it locally. Please check the screenshot for errors.
No description

Keep getting "cannot read properties of undefined (reading 'referencedTable') error

Hi folks, I tried to use drizzle APIs to query two tables with one-to-many relationship and join them using with. I looked out for other issues about that and checked if I had the correct relationships and schema setup. I have no broken config or relationship etc. You can see the relationships, my query and setup in the pictures. ...
word schema

insert multiple rows - onConflictDoUpdate

Hello, I am working on a project which is in prod now, I was originally looping through some data and inserting to my db in each iteration while having an onConflictDoUpdate for each one so that I can easily update data in said row. That has caused an issue with my db service which makes me think an insert multiple rows may be my best course of action. The only problem is that I don't know how to handle the onConflictDoUpdate because any of those rows can be conflicting and I'd like to update them if they are. Is there any way to do this? Thank you!...

how to generate type from schema

i ran drizzle-kit generate but doesn't see any generated file

how to setup nest.js with drizzle (postgresql)

I need help the way to setup nest.js with drizzle

Connection terminated unexpectedly after adding postgres.conf

Heyo, after adding a postgres.conf to my db, I always get 'Connection terminated unexpectedly'. I've tried multiple config setups, and this error arises as soon as I add any config to postgres. This is my docker postgres setup: ` db: container_name: db...

Insert returning and left join

Is it possible to do a leftJoin when returning() on an insert? Pseudo code that do not work (but to show an example of what I want). I.e. I want the user object returned on each splits I insert. ```...

Getting error Cannot read properties of undefined (reading 'map')

Here's my schema and my code, the commented one works well but the query version is not work
No description

Duplicate entry for auto increment column when execute insert statement

Default value is being inserted into the MySQL Auto Increment Column for insert statement. Below is the code to reproduce the issue. dependencies as below "better-sqlite3": "^11.0.0",...

Struggling to use Zod with Drizzle... Type errors around |undefined

```ts import { serial, text, timestamp, pgTable } from "drizzle-orm/pg-core"; import { createInsertSchema, createSelectSchema } from "drizzle-zod"; import { z } from "zod"; ...

raw SQL in schema

hi, i want to add postgres checks and since there is no support atm i wonder is it possible to add raw SQL to the schema file somehow? couldnt find in documentation

Defining disambiguating one-to-one relational query

I'm working with a schema that involves one-to-one disambiguating relationships, and I'm encountering an issue when trying to define these relationships concisely. Here's a simplified version of my schema: ``` model Transfer { id String @id...