danvk / effective-typescript

Effective TypeScript 2nd Edition: 83 Specific Ways to Improve Your TypeScript
https://effectivetypescript.com
Other
1.53k stars 226 forks source link

TypeScript and SQL: Six Ways to Bridge the Divide #28

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

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/

bbangert commented 1 year ago

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.

ECecillo commented 11 months ago

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 😅.

danvk commented 11 months ago

@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.