Drizzle Team

DT

Drizzle Team

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

Join

date column not being returned as string by drizzle

Hello, I have the following table: ```TypeScript export const productSnapshot = pgTable("product_snapshot", { productId: text("product_id").notNull().references(() => product.id), // You can use { mode: "bigint" } if numbers are exceeding js number limitations...

Studio issue with ::

Here's an interesting scenario. I'm using sveltekit and supabase. I was able to get everything set up fine. established three tables - introspect worked great - generated the schema - no issues. Loaded up another 35 tables - and now I'm running into this error when I try to pull up studio: node:internal/process/promises:289 triggerUncaughtException(err, true /* fromPromise */); ^...

Get total row count in select

Im trying to get the total row count of a joined table.
No description

How do i insert a Enum value into a table

Basic Setup ``` export const userRoles = pgEnum('role', ['admin', 'maintainer']); export const users = pgTable("userAuth", {...

Error running npx drizzle-kit push:mysql

When running the push command I get the error below. For example when I add a new table such as posts and run push...
No description

Is there a way to have a query- or transaction-level hook?

I want to: - for every transaction, before statements are run, issue a query against the database to set settings - for every query, if not in a transaction, open a transaction and set the setting, run the query, then close the transaction Is there any recommended way to do this with drizzle?...

ERROR: operator does not exist: uuid = character varying

```javascript export const hubPost = pgTable("HubPost", { id: uuid("Id").defaultRandom().primaryKey(), text: text("Text").notNull(),...

Update column A with the value of column B

I want to update column B with an updated value of column A So, something like this ```ts db...

Issues with supabase inserts with drizzle

```js const team = await db.transaction(async (tx) => { const [team] = await tx.insert(teams).values(teamObj).returning(); await tx.insert(team_stats).values({...

planetscale

simple question, is the mode: planetscale in the drizzle-orm connection builder deprecated? doesn't seem to exist there anymore

How would you write this REPLACE query?

UPDATE Examples
SET prompt = REPLACE(prompt, 'textToReplaceFrom', 'textToReplaceWith')
WHERE id IN [array of ids];
UPDATE Examples
SET prompt = REPLACE(prompt, 'textToReplaceFrom', 'textToReplaceWith')
WHERE id IN [array of ids];
...

Svelte and Drizzle and types?

Using Drizzle and NextJS, Drizzle provides types based on the schema. Using Drizzle with Svelte, all JS functionality works but none of the Drizzle provided types work. Instead, all auto types are: "any". Any thoughts? For example, using this schema.ts in NextJS...

Connecting to Neon through Drizzle via Cloud Function

Hi there! I have a nextjs app that is hooked up to neon via drizzle. I want to use some cloud functions to do some additional data transfer into the DB. 1. Does anyone have any advice on how to set up a cloud function with Drizzle? 2. How would you go about sharing the schema between the cloud function and the next app? I'm thinking I'll need to set up some sort of monorepo like turborepo but I don't know what the deal is with putting a google cloud function in a turborepo. ...

updatedAt timestamp update on DB row update

Whats the best way to update Postgres values for updatedAt --- I'm assuming there's a drizzle helper ? Can't find anything

Issue with diverging responses via RDS Wrapper on rawSQL query.

We've recently noticed that we're getting the raw response from RDS Aurora when doing a raw query. The issue seems to be known for some months already, but due to that our team is starting considering moving away from Drizzle. Is there any way we can assist with resolving this issue in some capacity? https://github.com/drizzle-team/drizzle-orm/issues/578...

Conditional findFirst

Is it possible to conditionally use findFirst, rather than having to chain the underlying model. E.g. ```const result = await db.query.users.findMany({...

Relational Queries: How to query based on the value of a joined table?

I have a table posts, where each post has a uid. I use relational queries to perform a join of the user into the post. Now I want to write a where(..) clause which checks whether the user.public field is set to true. However, the where clause does not allow accessing values of the user but only that of posts. How can I accomplish this? ```ts const res = await db.query.postsTable.findMany({ with: {...

Invert a boolean easily?

In SQL you can do
UPDATE my_table SET is_active = NOT is_active;
UPDATE my_table SET is_active = NOT is_active;
...

Cascade onDelete when not using FK relations

Is there a way to add a cascade on delete when declaring relations without FK ? For planetscale for example ?

Error following push

SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_resume Not sure what to do about this. Any thoughts?...