Drizzle Team

DT

Drizzle Team

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

Join

Timestamp from Postgres returns date object despite schema using string mode?

Hello team, I'm confused if this is a bug because I haven't seen any other threads about it. When I define my timestamp columns like this: ```TypeScript effectiveDate: timestamp("effective_date", { withTimezone: true, mode: 'string' }).notNull(),...

Transactions with the RDS Data API driver are not working

I've created a PR for this, see issue here: https://github.com/drizzle-team/drizzle-orm/issues/1171 As this is quite a blocker for us, is there someone who can look at this? There are also other RDS Data API things in the issue queue, like migrate not working, dates not working. We want to move away from the RDS Data API, but right now this is all we have 😦...

Maximum call stack size exceeded: orderSelectedFields

I'm migrating from Prisma, and trying to replace an aggregate query. I'm getting an error with the following query, which is—as far as I can tell—right from the documentation on aggregate queries: https://orm.drizzle.team/docs/crud#aggregations ```js await db .select({...

Bun `.get()` not working

Hi, just checking to see if there is any progress on this issue https://github.com/drizzle-team/drizzle-orm/issues/777. Maybe we also could a Discord tag for Bun?...

drizzle-zod failing

the createInsertSchema function is throwing errors when being used with @hookform/resolvers/zod, it's weird ```ts // Form component ......

Error: D1_ERROR: Error: not authorized

This works in local dev, and my other CRUD routes work without issue, however the following code throws error Error: D1_ERROR: Error: not authorized in production. Anybody have any ideas? Is something not supported in D1 like returning() or transactions or something? I'm using Miniflare in dev and it works here. ```ts...

How to updateNow for datetime?

How can I automatically update a datetime when the row is updated for mySQL?

drizzle-kit failing with Top-level await is currently not supported with the "cjs" output format

Can't seem to get drizzle-kit generate to run? PS \sst\packages\core> node --version v18.17.1 ...

postgres push issue

have a table like this ``` export const orgUserInfo = pgTable( "org_user_info", {...

Drizzle cannot run directly in loader/action

So I have been in the process of switching over from prisma to drizzle and I have hit a huge roadblock. Right now the only way that I can run queries is in server files. Every-time I try to run drizzle queries directly in loaders or actions it prevents the page from loading. The only way I can get it to work is to move the queries into server files and then import it into the route that I am using it in. Following the chain of issues down the call stack I end up in an aws-sdk file with the error code "No Providers in Chain"...

Schema in drizzle(pool, {schema}) doesn't work

I'm trying to add schema for the crud operations for my db. I'm adding schema to my drizzle() options but it does nothing (I'dont have any error inside index.ts file). I have to manually import all tables that I want to use. If I don't do that and insert table name anyway (no autocompletion from typescript) I'm getting an error: Cannot find name 'users'. Right now my code looks like this: // index.ts import { drizzle } from "drizzle-orm/node-postgres";...

Type of `tx` when using `db.transactions`

I want to use helper functions within db.transactions but I can't get the type of tx working so basically i don't know how to type tx in the updateUserNotifications function ```ts const updateUserNotifications = async ( userId: UpdateUserAttributes["id"],...

Update relationship within 1 query

is it possible to update relationships? for example i have a one to one relationship between users and notifications but i couldn't find any example of how i could update the notifications of a user in 1 query ```ts const updateduser = await db .update(users)...

getViewColumns function? (similar to getTableColumns)

Hello, in a situation where I need to join a view to a table. Here's the gist of my query code:
await db.select().from(myView).innerJoin(myTable, eq(myTable.someId, myView.someId));
await db.select().from(myView).innerJoin(myTable, eq(myTable.someId, myView.someId));
This works, however I'd like to be able to select only the view columns. For tables, we have the help of getTableColumns(), which is defined in the source code as:...

one to one query

I have a 2 models relation one to one, visit and visit_log, visit_log stores the visitId for reference to the visit table ```const result = await this.db.query.visit.findMany({ where: and(eq(visit.userId, userId)), with: {...

extract table names from db.query

Hi all, I want to extract the name of a table like this this.db.query however if I were to do this...

How does Drizzle Kit keep track of the migrations on PostgreSQL?

I don't see a ___drizzle_migration table or anything similar

implementing generics with crud and classes

I am trying to implement a base class, that could be overwritten/extended with the help of generics, but I am running into an issue with my create function, where I kinda get blown into generics hell the more I look at the type error. If anyone could help or just tell me that creating something like this is impossible please let me know haha. The issue I'm running into is in the create method where the values I'm passing in aren't happy with what it expects even though the Insert type is the inferred Insert of that specific table. Which doesn't make sense because update works as expected ```ts...

[SOLVED] When running a big bulk insert I get an error, MAX_PARAMETERS_EXCEEDED

I want to run a transaction that runs a large bulk insert but I get this error: ``` Error: MAX_PARAMETERS_EXCEEDED: Max number of parameters (65534) exceeded at toBuffer (/home/mast/workspace/work/mix-opt/dev/node_modules/.pnpm/[email protected]/node_modules/postgres/cjs/src/connection.js:181:20) at Object.execute (/home/mast/workspace/work/mix-opt/dev/node_modules/.pnpm/[email protected]/node_modules/postgres/cjs/src/connection.js:167:20)...

weird behavior with nextjs appdir experimental cache

I'm trying to use drizzle with planetscale's database-js inside of an unstable_cache (to leverage the tag caching system). ```ts export async function getArticles() { return await unstable_cache( async () => {...