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 do conditional joins with the query builder?

Hi, I'm looking for a way to do conditional join's without working with AnyPgSelect. Thanks in advance.

Custom column type with default not working?

I tried to add a new column with a custom type and a default value. but for some reason when I tried to db push, it warned me that it didn't have a default value and that it would truncate the tables. Am I doing something wrong? ```ts const unsignedBigInt = customType<{...

testing best practices

Can anyone share how they're writing tests that involve drizzle? Looking for something similar to these docs for Prisma: https://www.prisma.io/docs/guides/testing/unit-testing...

supabase workflow

Hey I'm trying to set up a sveltekit app with supabase + drizzle and currently what I got going is a schema file in /src/lib/db and a
drizzle-kit generate:pg
drizzle-kit generate:pg
script in package.json. Currently I am generating migration whenever I change schema and then copying the migration generated into the SQL Editor in supabase's website to change my db. Is there a command for letting drizzle handle the pushing for me? I know
drizzle-kit push
drizzle-kit push
doesnt support postgres yet so that one is out the win...

Error: self signed certificate in certificate chain

Hello, I am a new user of drizzle and trying to run the command for the first time:
drizzle-kit introspect:pg
drizzle-kit introspect:pg
But I got this error...

insert with InferModel not working

Hey, playing with Drizzle, like it a lot but I am having an issue where I inferred the model of a schema as type NewUser = InferModel<typeof Users, "insert">; and try to insert. It doesn't give an error, simply does nothing. In my app I have it do many different selects so I know the schema is fine and everything is connected and working. Yet when I execute this insert nothing is added to the db.
```js import { InferModel } from "drizzle-orm"; ...

mysql-core fails on TS build on 0.27.1

Getting this error when I try to build my ts node app

Use a different schema on postgres

Hello, I am currently trying to define a table with drizzle like this: ```typescript const rollupAccountResponsesDaily = pgTable('rollup_account_responses_daily', { rollupDate: timestamp('rollup_date', { withTimezone: true }),...

Specifying foreign key names in Schema

After introspecting from a database, and generating new schema with changes, the existing foreign key constraints get dropped and readded (arguably with a better name, but ignore that <a:pepe_shy:865718902628548618> ) is there a way to avoid/bypass this behaviour? for example, by manually specifying the name of the constraint in schema...
No description

Internal server error: Error connecting to database: fetch failed

I'm trying to send the following query to my db but it eventually times out, throwing an error: ```typescript const currentCity = await db.query.city.findFirst({ where: and(...

ERR_PACKAGE_PATH_NOT_EXPORTED on 0.27.1

I'm getting the following message using drizzle-orm 0.27.1. I've tried using various different node versions but currently on 18.16.1. Also tried rm -rf node_modules and pnpm i but still no change. I see there was another post back in 23 Apirl 2023 but couldn't find any helpful information on there. Any ideas?
No description

Error: Error connecting to database: fetch is not defined

Trying to use neon-http with SST ``` import { neonConfig, neon, Pool } from "@neondatabase/serverless"; import { drizzle } from "drizzle-orm/neon-http";...

good way to get the "count" for paginated queries

I'm doing the following to get the total count and the values in a paginated query: `` const fileCountRes = await ctx.db .select({ count: sql<number>count(*)`.mapWith(Number),...

Sqlite3 support for Deno

Apologies if I'm being dense, but is there support for deno with a local sqlite3 db? I can't seem to get better-sqlite3 working in Deno. TIA...

postges, auto-generated uuid as primary key

I'm looking to change all my tables from having a serial int primary key as ID what is the best way for generating the column definition in the drizzle schema file? Thank you...

Relational query `extras` are not properly adding sql

When I try to use the drizzle orm relational query like it is show in the docs I run into an error. Rather than taking the sql that I say and then adding as to alias the value it just requests the alias. ```ts const data = await db.query.user.findMany({ columns: {...

Schema not ingested with drizzle-orm/node-postgres

I have a db connection for production using Vercel Postgres. It works great. I'm trying to set up a dev connection to a local Postgres instance. I have the following code: ```ts...

Extract interface for table from schema

Can I extract an interface for a table from my schema without using it from the client? Something like "typeof [nameOfTable]" or something? Or do I need to define my own interfaces?

Including more than 1 relation in query throws error

If i try to include more than 1 relation i get an error 👇 ``` { "errorMessage": "could not identify an equality operator for type json", "errorType": "Hw",...

New neon http driver not working with pooled connections

is the new { drizzle } from "drizzle-orm/neon-http" not compatible with pooled connections? Getting error when I do:
const pool = new Pool({ connectionString: env.DATABASE_URL });
export const db = drizzle(pool);
const pool = new Pool({ connectionString: env.DATABASE_URL });
export const db = drizzle(pool);
...