Drizzle Team

DT

Drizzle Team

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

Join

Infinite scroll on Drizzle ORM not working

Please I haven't gotten the solution on how to solve the Cursor issue on Drizzle ORM. I was able to use a custom limit by using the Slice method on Javascript, however for the cursor scroll I still dont know how to add a cursor here: ``` const selectedMessage = limitUserMessage.map((_message) => ({ isUserMessage: _message.isUserMessage!,...

Using Query Syntax to filter by FK's field

hey there, I have a schema of users and their pets name and type. a user can only own one pet, and a pet could have several owners. how would I use query syntax to get all the users that own a dog (type === 'dog')? ```ts export const users = pgTable('users', { id: serial('id').primaryKey(), petId: text('petId'),...

[SOLVED] How to add new column?

Hello! Any ideas how to add a new column to an existing table? What I did so far: 1. Updated the schema to add a new column: ```...

nextjs, mysql2, await is only valid in async functions error

Hi, I'm new to nextjs and drizzle and I'm getting this error when trying to insert and delete from a mysql db on a client connection. All my other await calls are wrapped in async functions so I'm fairly certain this is the cause of the error. When I switch to using a pool connection I no longer run into the issue but I'm not sure if that's the best way to go about doing it. Like I said I'm really new to this so if I could get some help/explanation for how this is supposed to work I'd really app...
No description

How to create jsonb attribute index in drizzle

Suppose I have a table ``` Books author: varchar extra: jsonb...

yesterday, I tried to migrate from prisma to drizzle, but ultimately, I went back to prisma

yesterday, I tried to migrate from prisma to drizzle, but ultimately, I went back to prisma, because when I try to retrieve a list of things with its include relationships, it doesn't work.

Can't use ts alias in schema related files with drizzle-kit

Hey 👋🏿 I have a @ -> src path alias setup in my tsconfig. I made use of it in one of my schema files: ex: import { tableA } from '@/lib/entities/tableA/schema whenever I run drizzle-kit generate:XX, I get this error: ...

Using db. causes the whole app to hang forever.

drizzle.config.ts ```ts import type { Config } from "drizzle-kit" import "dotenv/config"...

Using arrayContains with a jsonb postgres type

arrayContains(matches.teamA, [id])
arrayContains(matches.teamA, [id])
teamA is a jsonb type of string[] i want to see if the id exists inside whats the best way of doing this...

FK identifier will be truncated... how to specify my own?

Im running into a warning because the FK constraint identifier is too long and will be automatically truncated. I would prefer to specify my own indentifier instead of it getting truncated... Is there a way to achieve this? any help is appreciated! ❤️...

How are you supposed to do multiple filters with Drizzle?

I've been using Drizzle for my project for a few weeks now. But I have run into a nightmare trying to use multiple filters with Drizzle. I have a table "events" I need to filter based on: - Event name (if a search query is provided) - Dates...

Query only one item from Many-To-Many

I would like only to take one stat not all the arrays. Is there a method to replace limit with something which returns only one item. ```ts const res = await ctx.db.query.servers.findMany({ with: { game: true,...

Error on db:push

Incorrect table definition; there can be only one auto column and it must be defined as a key

Column name alias

Is there a way to create column name alias in SELECT queries ? like (name as petName).

Broken query when parametized query is undefined

Postgres dialect generates broken query when one of the parametized query is undefined
sql`SELECT 1 FROM test WHERE a = ${true} AND b = ${undefined} AND c = {1}`
sql`SELECT 1 FROM test WHERE a = ${true} AND b = ${undefined} AND c = {1}`
generates
SELECT 1 FROM test WHERE a = $1 AND b = AND c = $2;
SELECT 1 FROM test WHERE a = $1 AND b = AND c = $2;
...

How to filter query based on children table?

Hi friends, first time using Drizzle so be gentle, this question may be dumb. I designed a model where I have a country table and a country_language table, as you can see in the attachment. Let's say that I want to return the country which has the slug (from the country_language table)="portugal-en". How can I write that expression?...
No description

Acceptance testing practices? In-memory Postgres mock for high-speed acceptance testing?

Hi! I'm using Drizzle with SvelteKit and Vercel Postgres. I would like to do extensive acceptance test coverage. I want my tests to be: * very fast: Postgres speed is a drag when you have thousands of test cases; * very reliable: not prone to network hiccups, paywalls, etc;...

Drizzle:push cannot read properties of undefined(reading 'name')

Database: Planetscale Hi team, I tried to run drizzle:push but it returns an error of TypeError: Cannot read properties of undefined (reading 'name') I have checked my tables and every columns has a name... Details of error be like ...

Circular dependent table types.

How to solve typing issue here (it gives me ANY type in both tables). Also i need reference in order to do operation like (onDelete, onCascade)
No description