jstack icon indicating copy to clipboard operation
jstack copied to clipboard

Please Don't Neglect Prisma; Request Jstack Not to Force Drizzle-ORM Binding

Open luz33c opened this issue 11 months ago • 4 comments

I'm a big fan of your work and appreciate the effort you put into jstack. I'm writing to suggest some improvements regarding ORM integration.

While Drizzle-ORM is a solid performer and might offer advantages in certain areas, forcing its use within Jstack is limiting. Many developers rely on Prisma, TypeORM, or other ORMs in their projects. A mandatory Drizzle-ORM integration creates friction for these users.

I propose the following:

  • Decouple: Remove the hard dependency on Drizzle-ORM.

  • Examples: Showcase Drizzle-ORM integration as one example within the official documentation and example repository. Crucially, add examples demonstrating integration with other popular ORMs like Prisma and TypeORM. This would provide a more realistic and inclusive view of how Jstack can be used.

  • Optional: Allow users to configure their preferred ORM. This could be achieved through configuration files or environment variables.

luz33c avatar Feb 15 '25 08:02 luz33c

I agree. I didn't like how they added drizzle and but not prisma. But maybe he didn't have the time to add. Anyway 1 is better than None :)

Shivam-002 avatar Feb 17 '25 07:02 Shivam-002

You can implement prisma really easily using the neon adapter for it, the same way that they do the db middleware for drizzle.

jcodog avatar Feb 23 '25 04:02 jcodog

Hi @joschan21, Is there any planned integration with Prisma in the near future? Also, is there a way to set it up manually in the meantime?

ElBaDaNoS avatar Mar 25 '25 09:03 ElBaDaNoS

For anyone wondering how easy it is, just like with drizzle-orm, it isnt built into jstack you add it yourself. It is this easy.

// src/lib/prisma.ts

import { PrismaClient } from "@prisma/client/edge";
import { withAccelerate } from "@prisma/extension-accelerate";

export const getPrisma = (database_url: string) => {
	const prisma = new PrismaClient({
		datasourceUrl: database_url,
	}).$extends(withAccelerate());
	return prisma;
};

then you add it to your app like so in a middleware for jstack

// src/server/jstack.ts

// rest of code

const dbMiddleware = j.middleware(async ({ c, next }) => {
	const { DATABASE_URL } = env(c);

	const db = getPrisma(DATABASE_URL);

	return await next({ db });
});

export const publicProcedure = j.procedure.use(dbMiddleware);

jcodog avatar Mar 26 '25 18:03 jcodog