Drizzle Team

DT

Drizzle Team

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

Join

Insert Schemas with onConflictDoUpdate

I'm trying to leverage the onConflictDoUpdate method to update a record if it already exists. The problem is that I create an insert schema with drizzle-zod that enforces the non nullable fields are set. In the case where the record already exists, it is valid to pass in partial data to my function, but that then fails the insert schema validation. Is there any way to parse the insert schema only if there is no conflict? My current workaround is to separate the insert and update logic....

[Error] Using Drizzle with Neon DB

Is drizzle compatible with neon pooled connections? Neon pooled connections don't support prepared statements, and it seems like drizzle uses prepared statements internally for all requests, but I'm not sure. https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.ts#L537 https://neon.tech/docs/connect/connection-pooling...

Migrations folder location?

Should the migrations folder be location somewhere in the src directory? Right now I’m experiencing errors with the migrate function trying to use the migrations folder in the root directory,. Copying the folder into src works (though i am now experiencing an unrelated error)

connection error, fetch failed

not sure if this issue comes from drizzle or planetscale but I'm getting this error while trying to do any queries from my db while on local dev ``` { e: TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:11576:11)...

Creating a Case-Insensitive Unique Index

I want to be able to select a user by their username but have usernames be case insensitive: ```ts const user = await db.select() .from(users)...

Drizzle update enum

Hi everyone I am currently playing with drizzle and enum with postgres. However it doesn't seems to allow update ? For example with this code: ```ts export const updateExerciseTag = (tags: Exercise["tags"]) => { console.log(tags); // ['chest','legs']...
No description

many to many relation with uuid's

i'm trying to create a many to many relation with uuids. if i try to push the changes to the database (pg) i got the following error: ``` error: column "userId" cannot be cast automatically to type uuid { length: 179,...

GIN index

index('content_json_index').on(content).using('gin'), how do i do gin index on jsonB? postgres....

drizzle-kit bindings error with bun using local sqlite file

When I use my local sqlite file instead of my Turso DB, I get an error running bunx drizzle-kit push:sqlite The command works fine when using Turso. I use Bun version 1.0.2...

Upsert question

I'm retrieving orders every 30 minutes that may be the same or some may be updated so I want the row to just update with the new information but I don't know how to do that, in the docs it only shows updating all the rows with a set value. Is there a way to update each row with the new data? I've attached an image to give an understanding of what im wanting
No description

How do relational queries work under the hood?

Just trying to further my understanding of how drizzle works - how would the following relational query be written using the sql-like drizzle syntax? ```ts const post = await db.query.posts.findFirst({ with: {...

One to Many problem

I am trying to make a form that let's you add a product, with different variants. Example Product: Journal, Variants (blue journal, red journal). So I made two schemas and enforced a one-to-many relation. Now the problem is...I can create a product without having a variation. What would be a good solution for this, where a user needs to upload at least one variant, but can also have an array of variants to be uploaded? ```javascript import { InferSelectModel, relations } from "drizzle-orm"; import {...

Type support for porting Kysely jsonArrayFrom to Drizzle

I am trying to port this functionality from kysley to Drizzle, but I am struggling getting the typing to work. Kysely function: ``` export function jsonArrayFrom<O>(...

Missing types for modules

Hello. I'm trying to setup drizzle-orm's fork on my local machine but stuck on step of installing dependecies (or something, I believe) in tests. Run commands: - pnpm i - pnpm run b - pnpm run pack...
No description

Inferred Types not picking up Relations

I'm having issues with my inferred types from the "Core Type API" not picking up relations. I am trying to model a 1-to-Many relationship between users and assignments . A user can "create many" assignments. My query looks like this: ```TypeScript...

Default now time for sqlite?

Does anyone know how to set default now time for sqlite-core orm? Thank you!...

one-to-many

I might be asking something simple or have to change my model but I thought I'd ask cause I've been stuck for a while. I have an images table ``` export const images = pgTable('images', {...

Modularize with Fasitfy and multiple Drizzle instances (NX Monorepo)

Hello folks hope u all having a good one! Quick question. I aim to create a series of Fastify plugins that are independent and composable. Each plugin should implement it's ownset of features. In this way our team can move fast and reuse a specific set of those plugins (and create other if needed) when a new project starts. I wan to use this dreadful and terrible (no better than Prisma) ORM to handle the persistence layer of those plugins....

Get Raw query string of a relational query in drizzle

I need the raw query string of a relational query to perform an explain command. The docs only explain this process for the non-relational queries :/...

Drizzle support SELECT FOR UPDATE of postgres to avoid logical race conditions ?

I have a similar use case like this: https://on-systems.tech/blog/128-preventing-read-committed-sql-concurrency-errors/ Currently I use a mutex in my node main process, but I think is better to move this to the db. If is possible can you show me a minimal example ...