Drizzle Team

DT

Drizzle Team

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

Join

Is it possible to use nanoid for uuid?

Hi, I want to see if I can customize the uuid generation but I have no idea how to do it. Is there a code sample that I can follow? Thank you...

findMany without additional options

When using const results = await db.query.habits.findMany() in my project, results is []. If add any option like ```ts const results = await db.query.habits.findMany({...

Not equal with relational queries

Has anyone used ne with relational queries? When I use the callback syntax, I get the following type error: ```ts...

What is wrong with my one to many schema?

``` export const jobs = pgTable('jobs', { id: serial('id').primaryKey(), user_id: varchar('user_id', { length: 15 }) .notNull()...
No description

only first db migration runs

thought I'd repost here in case someone else is experiencing this https://github.com/drizzle-team/drizzle-orm/issues/1017

Preferred way of adding generated column and unique partial index in schema

I want to add something like this sql in my schema: ``` ALTER TABLE TaskUsers ADD COLUMN is_assignee BOOLEAN GENERATED ALWAYS AS (role = 'assignee') STORED;...

Query builder insert

What is the syntax for creating an insert query with the query builder ? There are some examples on the website showcasing select, but i'm looking for insert logic, which the query builder under drizzle-orm/sqlite-core is missing ( seems to only have select on the QueryBuilder)...

Correct typing when using "columns" as param

Hello awesome people at Drizzle, I'm having this problem and I don't know how to fix it. So... I have this RoleManager service that has a method called getByName that can take in columns. The problem is that I can't seem to type this query in a nice way and what I've done doesn't tickle me the right way. xD...

Can I create a default row when `drizzle-kit push`

I have a config table and I want to have some default data when push to db. Can drizzle-kit create it automatically for me? Maybe like database seeding?

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];
...