danvk / effective-typescript

Effective TypeScript 2nd Edition: 83 Specific Ways to Improve Your TypeScript

Home Page:https://effectivetypescript.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeScript and SQL: Six Ways to Bridge the Divide

utterances-bot opened this issue · comments

TypeScript and SQL: Six Ways to Bridge the Divide

Effective TypeScript: TypeScript and SQL: Six Ways to Bridge the Divide

https://effectivetypescript.com/2023/08/29/sql/

I've been trying out kysley, its pretty nice. Drizzle has come quite a ways as well. For a more full featured ORM, MikroORM is pretty slick and implements some nice patterns like Unit of Work, and the Identity Map that Prisma and TypeORM are lacking.

Hi, great post !
I was wondering if using only the Client of Prisma to generate types and populate the database using the prisma.schema was a viable option for raw queries ?

I'm kind of newbie in this field so be gentle if I'm wrong 😅.

@ECecillo with the big caveat that I've never used Prisma, once you use something like prisma.schema as your source of truth, you're squarely in the ORM camp. Looking at their docs on raw SQL, you can associate TypeScript types with your queries but it's up to you to make sure they're right. The beauty of PgTyped is that you write raw SQL and it does this for you. You don't need to worry about keeping the types in sync with your queries. That being said, I don't see any reason why you couldn't use PgTyped in conjunction with Prisma.