Drizzle Team

DT

Drizzle Team

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

Join

relations help

how can i have a many-to-many relation for example a user can have multiple followers and can follow multple users ```js export const users = pgTable( 'users',...

Do I need to close the DB connection after running a script using drizzle?

I have a very simple script to import some CSV data: ```typescript import { System } from "@foo/core/system"; import { readFileSync } from "fs"; ...

Error introspecting Supabase auth schema

When trying to introspect the Supabase auth schema I get this error: ``` C:\app\node_modules.pnpm\[email protected]\node_modules\drizzle-kit\index.cjs:12431 name: tableCompositePkName[0].primary_key,...

Issues with timestamp precision with postgres

Hi, I posted the other day about a bug with the date, but it seems this issue runs deeper. https://discord.com/channels/1043890932593987624/1043890932593987627/1136224592764080268 I am also using timestamp which has a similar issue, when using mode string drizzle is returning a Date instance (conflicting with the generated types)...

Relations not building into type

Im having an issue where the relations types are not correctly being tied to the table ``ts const todaysVisits = await db.query.visits.findMany({ where: sqlDATE(${visits.date}) = ${date.format("YYYY-MM-DD")}`,...

JS API for generating CREATE TABLE sql?

I saw a message that a JS API is coming for drizzle-kit, which will be great. In the meantime is there an existing method to generate the CREATE TABLE sql from table schemas? My use-case: I'm writing tests, for which I would normally use an in-memory sqlite database, but I need to generate the tables in the DB as I would with drizzle-kit push....

Dont throw error if the relations is not correct

const posts = await db.query.posts.findMany({ with: { comments: true, }, });...

tsc fails to build due to errors

When I run tsc to compile the project to javascript, I am getting the following error: ``` Found 4 errors in 2 files. Errors Files...

trying out neon.tech should i use "Pooled Connection"?

the title says it all, i'm going to try moving to Neon database (postgres) but i'm not sure if i should use a pooled connection or not. Thank you...

Discrepancies Between Raw SQL Queries and ORM Operations: Why Might They Behave Differently?

What could be the potential reasons for a query executed using the execute method to function correctly, while the same query using an ORM approach (i.e., db.insert().values(), etc.) doesn't produce the expected results or doesn't work properly? First screenshot doesn't work, while second one works properly

I need help generating a query for a schema

Hi guys I have the following schema ```ts export const companies = pgTable('company', { id:serial('id' as string).primaryKey(), name:varchar('name' as string).notNull(),...

Best way to omit a field (e.g. password) after findMany from schema?

Let's say we have the following: ```typescript export const User = pgTable( 'user', {...

How to implement interface for table?

Say I have an interface of User ``` interface User { id: string,...

onDuplicateKeyUpdate

Is this the correct way to use this method? Can't find documentation ```db .insert(schema.item) .values({...

drizzle weird error message on database operation

I am getting this weird error when doing database operation

permission denied on insert

I have a drizzle user with full permissions set but I am getting permission denied errors, I have rls enabled

How can I reference the RelationalQueryBuilder and RelationalQuery types?

These types are currently not exported from the library AFAIK. I would like to reference these types to build a generic query builder for our internal use. How can I get to them?

Dropping unique constraint cant push to db

I have this key here nftCollectionIdKey: unique("Pool_nftCollectionId_key").on( table.nftCollectionAddress ), ...

I'm getting circular dependency problems because each table relation is declared from the table file

Is there a better way to declare relations ? What I ended up doing was declaring all my relations in a separate file "relations.ts"....

How do I import a type?

This might be something I'm just totally overlooking, but I'm used to prisma where you can just import any schema you've defined as a type. For example, if I have a table posts, I'd expecect to be able to import a Post type to be used in one of my child components. Is this possible with Drizzle? Or have you all found it to be unnecessary...