Drizzle Team

DT

Drizzle Team

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

Join

how to type dynamic where condition

i'd like to do something like ``` async function selectEventByCondition(condition) { return db.query.events.findFirst({...

How am I supposed to put unique constraints on columns

Hey! I was looking at the docs for the implementation of unique constraints and index but I think either the docs are outdated or there seems to be a bug since I could neither find the function .unique() to chain in the schema nor could I import the unqiue method from "drizzle-orm/pg-core"

Does drizzle allow you to access db in frontend of nextjs (app router)

I am currently using nextjs, planetscale and prisma for my web app. Prisma doesnt allow db access in the frontend, will drizzle allow me to access the db in the page file?

Running into an error when runing `drizzle-kit push:mysql` yet i haven't changed anything

So i seem to be running into this error: ```bash $ pnpm db:push
[email protected] db:push G:\GitHub\Meally\apps\meally drizzle-kit push:mysql --config=drizzle.config.ts...

Drizzle Kit - Where to store relations?

Seeing as when pull operations occur it overwrites the local schema, is there a good place to keep relations? Just relations.ts somewhere in my project?

unknown command: drizzle-kit

Can't seem to get the command to work. Followed the instructions of the quick start guide. Any ideas?

Auth.js adapter import causes module not found error

Hey there! I want to build an authenticated app using Auth.js and the newly released Drizzle adapter. I've done the setup exactly as described here, but am getting the following error when running:
[ERR_MODULE_NOT_FOUND]: Cannot find module 'pathtoproject\node_modules@auth\drizzle-adapter\lib\mysql.js' imported from pathtoproject\node_modules@auth\drizzle-adapter\index.js
I.e. my hooks.server.ts file:...

Insert One to Many

How can I insert relations as well at create the parent? ``` import { Customer } from "@/types/customer"; import { NextResponse } from "next/server";...

Renaming pgEnum results in truncation?

I've been using drizzle with MySQL for a while, but I'm new to PG. I encountered an error where I had two different enums with the same column name status on two different tables, and Drizzle just chose one of the enums for the migration and didn't include the other. I was able to solve this by just changing the column names to project_status and comment_status (which might be better anyways, so its fine). But when pushing that migration I got a new warning saying that changing the column datatype from status to project_status would truncate the table, even though neither the enum datatype itself nor the default value had changed at all. Just the name. So I guess I'm just wondering if anyone has encountered anything similar, and if you were able to find a solution, or if this might be worth opening issue over. Or rather if I just clearly have a misunderstanding of how PG works, please let me know lol. Thanks in advance!...

Drizzle Kit + Planetscale example?

I was hoping there would be an example of how to integrate the two. Planetscales docs are just OK, so I'm wondering if anyone has done this before and would be willing to share some code,

Issue with Jest tests in Next.js

I seem to be hitting an error with Jest tests when using DrizzleORM in my tests. I get
Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
...

explain relationName please

Could anyone explain how to use relationName when you have many to many for example. Found following on github:
"relationName is already supported, just not documented. So you can use it exactly as you've described. You'll just need to add where clauses to the corresponding with entries."
"relationName is already supported, just not documented. So you can use it exactly as you've described. You'll just need to add where clauses to the corresponding with entries."
https://github.com/drizzle-team/drizzle-orm/issues/811...

Error While db-push

I last pushed a change 2 days ago, and this error didn't occur. Today, when I added description to it and tried to push, it gave me this error. I wonder why.

Type error: Type parameter has a circular constraint

Hi all! Trying to figure out this error I'm getting when running next build. Thought I'd drop it here in case anyone else has run into it or has any tips for debugging: ``` - info Checking validity of types... Failed to compile....

There is not enough information to infer relation

```js export const historyRelations = relations(histories, ({ many }) => ({ files: many(historyFiles), })); ...

Getting Invalid default on timestamp when pushing schema to Planetscale

Getting the following error. Is there another method instead of defaultNow() for timestamps?

How to flatten select results from query with left joins (one-to-many)?

Is there a way to achieve this? Current behavior in drizzle works like this (assuming we're printing the variable "result" which is supposed to be an array of person with all their hobbies, one to many: ```ts // NOTE: I've read a portion of the docs and it says something like //using a reduce function. I'm looking for a solution that is more // of an abstraction that works out of the box - just like how...

"mode" not defined in drizzle config 0.28.1

With the new update i've added the "mode" field for planetscale however my ts is mad at me

how to convert serial to uuid type

Hello I'm trying out drizzle but i'm stuck on a problem I created a todos table with id as serial type, migrated and pushed it to my db, now I wanted to change the type to uuid but the following error appears on my console PostgresError: column "id" cannot be cast automatically to type uuid...