Drizzle Team

DT

Drizzle Team

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

Join

Drizzle and Cloudflare D1

I created a svelte repo using create cloudflare cli. I found ```ts...

Output drizzle schema to json or similar

So I have a postgres database that is basically my primary source of truth for nutrition and excercise data I want to sync this to my typesense instance (I can do this through postgres trigger) and to a sql lite file I store on my clients mobile devices for offline support. But my question is there anyway to get my postgres drizzle schema as json string or something like that so I can manage syncing the typesense collections schema when i update my drizzle schema with a custom script....

db.query not updating

Hey all! I recently refactored my schema to take advantage of the findMany and findFirst functions. These are my collectionsTable relations: ```export const collectionsRelations = relations(collectionsTable, ({ one }) => ({ author: one(usersTable, { fields: [collectionsTable.authorID], references: [usersTable.id],...

Handling errors in Expo

Im using the setup provided at https://orm.drizzle.team/docs/connect-expo-sqlite. While developing today I stumbled across an UNIQUE constraint error which was expected. When looking at the error in the catch clause I noticed that the Error was just a plain JavaScript Error which makes it hard to parse the errors and handle them correctly, example: Error: Call to function 'NativeStatement.runSync' has been rejected. → Caused by: Error code : UNIQUE constraint failed: column1, column2 at construct (native)...

unionAll in pgView

How can I use a unionAll in a pgView? I've included an example. https://drizzle.run/enckmzihpalip5k0a8ahp9he...

Time type query inconsistencies

I got two different queires: ```ts const result = await database.query.employeesTable.findFirst({ where: eq(employeesTable.id, employeeId), with: {...

Do I need to manually add indexes on foreign key columns when working with PostgreSQL?

Hello, Here's example schema: ```ts export const orderItems = pgTable('order_items', {...

trying to use $count withing query relational api

PostgresError: column projects.project_id does not exist ```ts const projectsInQueueWithDrizzle = await db.query.projects.findMany({ with: { matches: true,...

Cloudflare d1 on cloudflare pages functions

In the drizzle docs, the following code is mentioned to work with cloudflare workers but how do I make it work for cloudflare pages functions ``` import { drizzle } from 'drizzle-orm/d1'; export interface Env {...

Complex seeding tasks

Heyo, I am just transitioning to drizzle-seed, but I am struggling to replicate the power I had with my monolithic file of for loops. One example is we have a table called week_number_systems which holds things like ISO 8601, US Sunday etc. Then, we run a task to populate another table called week_definitions. The week definitions table has each row represent a week, and a week number system can have many week definitions (one to many). This is so that our app's schedule is dynamic, and can support any type of week. The week definition has a starts_at and ends_at, as well as a year and week (because 1 day, can have have a different week number or year as per ISO 8601 or US Sunday)....

Is it possible to seed nested referenced entities?

If I have three tables with a one to many relations: Agency -> Project -> Domain I see in the docs that with refine you can create references from one table to another: ```ts...

Field type error on insert

I'm trying to insert data into my table, but I'm getting a type error. In my table, the expiresAt field is of one type, but when I insert it, it appears as another....
No description

schema in multiple files breaks types

I have split my schema into multiple files and exported them all like before with a single file. but now some of the types aren't working anymore and properties are missing/undefined on tables. if I place everything in a single schema again, it's working fine. I haven't changed any of the exports either....
No description

when running postgres in docker, drizzle cannot connect to it, says database doesnt exist

basically all i did is ./start-database.sh the env updated itself but it says that databse does not exist :/ i checked in docker desktop and the container is running

recommendation on changing data type of column?

what's the recommended approach here, e.g. changed from text -> double precision and I got this expected error error: column "time_waiting_for_builds" cannot be cast automatically to type double precision i'm wondering how to go around these kind of things. would editing the resulting migration sql be an anti pattern? is there a recommended approach to do these things?...

TypeError unless column is notNull

gave the following error. Object literal may only specify known properties, and <column> does not exist in type: schema.ts: ```ts...

Update returning with some relation

As the title says I am updating an object using this syntax: ```ts const idToUpdate = "someId"; const newEvent = {...};...

reference fails with Cannot read properties of undefined (reading 'id')

I have a foreign key reference that will not resolve. It seems that the other pgTable is undefined when it tries to resolve. I used madge to check and i have no circular dependencies. Does anyone have a strategy for how to find my error?

Drizzle not creating table

Hello, Do I need to manually create the tables? I have schema set up but its not creating the tables?...

Best way to insert thousands of records.

Hi, I've a use case where we get thousands of items from an API and I need to insert them into our DB. Right now my stack is node with nestjs+drizzle+postgres (aurora rds). As far I know the best option in PG for large inserts is to use COPY command....