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 relational query, filters

I'm trying to add some simple filters to my query, as according to https://orm.drizzle.team/docs/rqb#select-filters I've tried both where: eq(users.id, 1) syntax, and where: (users, { eq }) => eq(users.id, 1), - both result in
Type '{ where: SQL<unknown>; }' is not assignable to type 'true | { columns ?: ...
Object literal may only specify known properties, and 'where' does not exist in type '{ columns ?: .....
Type '{ where: SQL<unknown>; }' is not assignable to type 'true | { columns ?: ...
Object literal may only specify known properties, and 'where' does not exist in type '{ columns ?: .....
How do I add more filters to a relational query?...
No description

PostgresError: unrecognized configuration parameter "schema"

Hi everyone. I'm migrating a pretty large app from Prisma to Drizzle and its been great so far, but I'm having problems with my seed script: ```ts const client = postgres(DATABASE_URL!, { max: 1 }) const db = drizzle(client, { schema })...

How to get better errors?

On line 44 in the image, there is an error where I compared the userTable to the storedToken instead of the emailVerificationTokenTable. Since this would never work, shouldn't the error be more clear? The error it throws says that the column user.id does not exist. Of course, that column does exist, it just doesn't exist on the emailVerificationTokenTable. Is there any way to get errors that reflect this kind of mistake?

bug: three column unique index no change never detected

ex: ``` uniqueReactPerPost: unique('post_id_reaction_user_id').on( postId, reaction,...

Drizzle NextJs Middleware

Hello, I'm currently using NextJs middlewares to protect my application. In my middleware, I have a query running to check if the sessionToken is valid. But whenever I visit the protected page I get the following error. ``` Server Error...

Unable to get local issuer certificate

getting the above error, using @vercel/postgres and drizzle-orm/vercel-postgres. I think Ive got it all setup correctly. (MacBook Pro, Sonoma 14.0) (following is snippet of relevant parts I think, complete code can be found here: https://github.com/bryce-frontend-mentor-projects/devlinks)...

Many -> Many relation with additional where clause to make it One > Many

I'm trying to work out if this is possible. I have the following DB schema: ``` export const paymentPlans = pgTable( 'payment_plans',...

Reuse with in multiple queries

This is what I currently do, but I would like to be able to reuse the with clause in multiple queries. Is there a way to do this? ```typescript export const matchesWithPlayers = () => db.query.matches.findMany({ with: {...

Automatic migrationbs

Heyo, I am currently thinking about using SvelteKit with drizzle for a new project. Currently I use NestJs +TypeOrm, and one thing I like is that my migrations get automatically applied whenever I push an update into production. (Work locally, change database entities (e.g. add a column, create a new seed query), and I don't have to worry about manually starting any migrations on the client's server). Is the same possible in drizzle?...

error: Failed to run "drizzle-kit" due to error AccessDenied

hi, i'm currently getting that error when i use bunx drizzle-kit or bunx prisma, i tried many solutions 😦 i am using PopOS...

is there a way to create virtual columns in postgres?

I could just create a migration but I want the type to be correct, if it allows null it will be wrong and if it doesn't it will require it in inserts

Bigint showing incorrect value from db

I have the following schema ```typescript export const guild = pgTable('Guild', { id: bigint('id', { mode: 'bigint' }).primaryKey().notNull(),...

Select item collection together with item count

Heads-up: I'm an SQL & Drizzle newbie I have 3 tables: users, flashcard_collection and flashcards flashcard_collection has a creatorId foreign key which indicates what user a collection belongs to flashcards has a collectionId foreign key which indicates what collection a flashcard belongs to...

Delete from join

Is it possible to do something like this: ```sql DELETE P FROM Product P...

Use column name in like operator

I'm trying to create a query with a join where I get all entries whose value starts with the value of the root table. e.g. Tags = { ..., tag: "some", ... } tagsWithNoteIds = [{ ..., tag: "some", ... }, { ..., tag: "some/string", ... }] ...

I am getting below error as I use drizzle, these are repeating too often. I am using postgres driver

{ severity_local: 'NOTICE', severity: 'NOTICE', code: '42622', message: 'identifier "person_personRelationships_relatedCommonPerson_commonPersonTranslations" will be truncated to "person_personRelationships_relatedCommonPerson_commonPersonTran"',...

drizzle-kit and bun:sqlite

How do I work with bun:sqlite in drizzle-kit? I set up a config file without a driver, and it seemed to default to better-sqlite3, which doesn't have bindings for bun (that i know of). In the meantime, I'm running drizzle-kit through node, but I'd like to avoid the multiple runtimes if possible!...

Using drizzle in single tenant applications

Our use case is that we have single tenant applications that are spun up per client, each with their own database. We want to use drizzle to generate a "fresh" database when it is provisioned. Normally for existing databases, drizzle will generate new .sql files to alter columns, tables, etc, creating a time series sql steps to get to the happy current state of the db. When spinning up a fresh database, it would be more efficient to run a generated .sql file that is just the end state. For example, a table with column "test1" that was renamed to "test2" would generate two .sql files, one to create the column as "test1" and one to alter table and rename to "test2". However, for a fresh database it would be ideal to just skip to creating the column as "test2" when you create the db....

many-to-many query with where filter on second level

Hi, I'm trying to create a many-to-many query where I can filter on the second "with" level.. My schema looks like this: ```ts...

zod schemas, main schema, and relations in separate files

I assume it's fine to put relations, zod schemas, and the main schema in separate files, right? If I'm understanding correctly, zod schemas aren't needed by the client, so they can be wherever and migrations don't need relations, so as long as I add the relations and main schema to the client everything should work. Any unforseen issues here?...