Drizzle Team

DT

Drizzle Team

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

Join

Filter based on join data

Hi, would it be possible to query a list of student and filter by the name of its coach. The data is <student>.coach.fullname where coach is added as a with join. I would like to get every student that have a certain coach.

Using relation columns in where clause (Drizzle playground provided)

I have a one-to-one relationship with a schema defined like: https://drizzle.run/uwkkt8l10cgp5okr1r41tjfu When I run that query, I get the following error column agent.deleted does not exist. Why can't you reference relation columns in a top-level where clause? Is there a better way to do this without using the select API with joins?...

StatementTimeoutException: Request timed out

Hey! So I'm using SST v2 on my project. As database I'm using RDS Aurora (https://v2.sst.dev/databases#rds, https://v2.sst.dev/constructs/RDS) with PostgreSQL engine. I have followed the guide from SST docs and take a look on Drizzle docs too (https://orm.drizzle.team/docs/connect-aws-data-api-pg, https://orm.drizzle.team/docs/perf-serverless). But recently I noticed that I have run into StatementTimeoutException: Request timed out issue. I'm getting this error in SST console: `StatementTimeoutException: Request timed out at de_StatementTimeoutExceptionRes (file:///var/task/packages/functions/src/api/permissions/get-user-permissions.mjs:62242:21) at de_CommandError (file:///var/task/packages/functions/src/api/permissions/get-user-permissions.mjs:62064:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)...

Self-referencing many to many relation

I've been trying to point some interfaces to similar interfaces using the following code: ```ts export const interfaces = createTable( "interfaces",...

Using inferred schema types in Next.js client components, 'server-only' breaks Drizzle Studio.

Im working with Next.js 14 app router. I'd like to use Drizzle's inferred types across my application, including client components. Schema: ``` import "server-only";...

How to set PRAMGA for Sqlite

Really not sure how this would be done here. Some of them are permanent but some need to be set on every connection. in my example something like: PRAGMA foreign_keys = ON; PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;...

Error: Unknown column 'c.GENERATION_EXPRESSION' in 'field list'

I have some error when start run drizzle-studio i just follow https://orm.drizzle.team/drizzle-studio/overview with bun, then bunx drizzle-kit studio. I'ts was opened to https://local.drizzle.studio/ but i got the error like this...
No description

Using drizzle postgres with trpc in Next.js app

I'm getting the following error with the below code: Module not found: Can't resolve 'dns'. For some reason, my Next.js app is trying to load drizzle on the client where it doesn't have access to Node modules. Has anyone ever run into this before? ```ts import { publicProcedure, router } from "../trpc";...

Cant get custom type to work with default value

I made a custom type for the interval type in postgres default values keep writing [object Object] to the migration file regardless of what I output in toDriver...
No description

Cannot read properties of undefined (reading 'endsWith')

Y try to push this in my supabase database
export const user_provider_topics = pgTable( 'influencer_topics', { uuid: uuid().defaultRandom().primaryKey().notNull(),...

How to select a subset of fields from a JSONB?

I'm using Postgres and can't figure out how to select a subset of JSONB fields? Is this supported yet?

How to resolve mutiple queries in a single request to postgres database?

I have more than one sql select statements that need to act independently and are not related to each other. Is there a clean, type-safe way to fetch results for all these select statements in one request to postgres instead of having to use Promise.all and making a seperate request for each select statement? Most probably what I'm asking for is a single select statement that contains the logic for all the three select statements below. ```typescript const usersQuery = db.select().from(users).where(eq(users.age, 24)); const accountsQuery = db.select().from(accounts).where(eq(accounts.verified, false)); const sessionsQuery = db.select().from(sessions).where(inArray(sessions.userId, userIds));...

Semicolon separated emails using drizzle-zod.

I have the following Schema definition for drizzle-zod: ``` export const RegistroSchema = createSelectSchema(registro, { correo: (schema) => schema.correo.email(), retencionRenta: (schema) => schema.retencionRenta.optional(),...

Seeding remote D1 database by running `.ts` file

how to seed data by running .ts file for a remote D1 database?

Deprecated function table.d.ts(26, 8): The declaration was marked as deprecated here.

``` import { pgEnum, pgTable as table } from "drizzle-orm/pg-core"; import * as t from "drizzle-orm/pg-core"; import { createInsertSchema, createSelectSchema } from "drizzle-zod"; export const customers = table(...
No description

Drizzle studio not updating

Hello, have been trying to add to my schema file: ```const RoleEnum = pgEnum("roles", ["user", "admin"]); export const users = pgTable("user", {...

Drizzle Expo Sqllite

is it possible to implement backend Sync with drizzle-expo-sqllite, like recording all changes in a Queue and running sync periodically(or when App is online), Similar to WatermelonDB? I am new to Drizzle and sqllite, any pointers will be appreciated....

Insert IF NOT EXISTS

I'm attempting to insert a row to a table, but only if a row doesnt already exist which has the same value for the column "content" and if it does, return that row like this: ` const [resource] = await db .insert(resources) .values({ content: 'John Doe' })...