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 Posts by categories?

I'm learning drizzle and I've come to a wall, how do i filter posts by category id bringing posts with all their respective categories? `const postsByCategory = await db .select() .from(postsOnCategories)...

What structure is expected when using the http-proxy?

When I run this code i get a object with a empty id and name. ```ts const db = drizzle(async (sql, params, method) => { const result = await database.select(sql, params); ...

inferSelect doesnt take into account defaults in schema

```ts export const event = sqliteTable('event', { id: integer('id').primaryKey({ autoIncrement: true }), name: text('name').notNull(), startTime: integer('start_time', { mode: 'timestamp' }).notNull(),...
No description

Drizzle studio : Many To Many : There is not enough information to infer relation

I can't seen to get rid of the following error with Drizzle studio :
Error: There is not enough information to infer relation "__public__.course.recommendations"
Error: There is not enough information to infer relation "__public__.course.recommendations"
...

Migration Issues: can't ALTER TABLE to serial in Postgres / Drizzle-Zod Interaction

In migrations generated for Postgres, changing a primary key from type 'integer' to 'serial' will generate an error. Executing drizzle-kit will generate a migration containing the following line: ALTER TABLE "users" ALTER COLUMN "id" SET DATA TYPE serial; which, when the migration is done, will generate an error: ...

code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'

i'm trying to start a new project using pnpm and create-t3-app. initial setup goes fine, but once i've linked up with an awake, free-tier, planetscale db and try to run pnpm db:push, an alias for dotenv drizzle-kit push:mysql, i get the following error. i have tried downgrading drizzle-kit to ^0.19.3 as suggested in this thread https://discord.com/channels/1043890932593987624/1188413169668980768/1188647000707694622, which seems to be about a similar issue to mine, but to no avail....

Help Needed: Adding Message Count and Filtering by UserId in DB Query

Hello everyone, I'm working on a feature where I need to fetch data from two tables: companion and message. My objective is to retrieve a companion from the companion table, all related messages for that companion from the message table, and include a count of these messages. An additional requirement is that the messages should be filtered by userId. However, I'm encountering challenges with incorporating the message count and filtering in my database call. Here's my current approach:...

Update and return a single row only when using .update()?

Hi, I have the following drizzle code which updates levels in a table. ```ts...

drizzle-kit snapshot files malformed error

I’m getting snapshot “xxxx_snapshot.json data is malformed" errors trying to generate a schema change. The error appears for each of the existing snapshot files. There were no schema updates since June, so all of the snapshot files are what was generated by the version available at that time or earlier (checked-in as generated). The latest version appears not to be able to work with these files, as the error message appears for every snapshot. I tried downgrading to 0.19.13 but then I get an error that the version is outdated an to upgrade. Any recommended approach to get the snapshot files up-to-date?...

local.drizzle.studio SSL protocol errors

I'm having trouble running drizzle studio. I believe this started with the move to https://local.drizzle.studio. While I can see records in my database without any issues I can't run any queries, as I get SSL protocol errors from https://localhost:4983.

Question about handling upsert case

What is the best way to handle this case for upserts? in prisma, my upsert code looks like this: ```ts await prisma.posts.upsert({...

Property 'employees' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is miss

I am getting an error trying to do a findmany on a table. Property 'employees' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB type?">' Not sure what I have misconfigured. Here is the query: import { MySql2Database } from "drizzle-orm/mysql2";...

Advanced aggregations help

Here's a Drizzle query that I'm trying to do : ```ts const videoLogs = db .select({...

How to define type of table with all relations included?

Say I have a a table users and a user has many posts, so I define a relationship as shown in the docs If I want to define a type that is "user with posts" that would be the result of: ```ts await db.query.user.findFirst({ with: { posts: true } });...

What is the purpose of exporting relations

https://orm.drizzle.team/docs/rqb#declaring-relations What is the purpose of exporting declared relations? Also, I feel like it would make sense that relations would be an optional argument in pgTable, not a separately declared item...

Best way to query jsonb field

I can't find any relevent thread other than this one (https://discord.com/channels/1043890932593987624/1164542422328553502) if i have a column like: ```ts myData: jsonb('myData').$type<{a: {b: string} }>().notNull()...

trying to retrieve data

trying to retrieve data of table which contain ref id of another table working perfect on my localhost but when i try to get the same data after push the code to domain it shows empty even data is available in db table should i need to define anything else to get the data here is my api endpoint export const GET = async (request: NextRequest) => { const token = request.cookies.get('session')?.value as any console.log(token, 'Token');...

Is FULLTEXT Search Possible in MySQL via FULLTEXT Index?

Hello everyone, I am currently working on a project using Drizzle ORM with a MySQL database, and I'm looking to implement full-text search capabilities. While I am aware that MySQL supports FULLTEXT indexes (as detailed in their documentation: https://dev.mysql.com/doc/refman/8.0/en/fulltext-natural-language.html), I am uncertain about the integration of these features with Drizzle ORM. My questions are as follows:...