Live data from Hacker News

Prisma – ORM for Node.js and TypeScript

prisma.io

41–50 of 260 posts

Re: Prisma – ORM for Node.js and TypeScript

#42
post #2

I'm just about to start working on DB layer for our app with TypeScript. Any other alternatives to prisma you guys prefer and why?

(haven't tried Prisma) TypeORM -> classic ORM, the "default" choice in node, but not very mature compared to what exists in Java or things like Django ORM. In my experience it's not an amazing lib, transaction management is a bit painful, I've seen a couple bugs happen. Knex -> it works but not sure why you'd use that rather than TypeORM MikroORM -> not a lot of experience, one of my colleagues really likes it, read…

TypeORM is poorly maintained (the lead author had a breakdown and appears to be inactive, and failed to delegate ownership to others), and is riddled with bad abstractions, poor design choices and an enormous pile of game-breaking bugs that make the TypeScript types unsafe and it’s usage clunky and dangerous. I would absolutely use knex, which works, over TypeORM, which routinely doesn’t.

Re: Prisma – ORM for Node.js and TypeScript

#43
post #25

Earlier quoted context omitted.

> GraphQL N+1 issues are a thing of the past. Huh, care to explain this one? I’m using Prisma with Apollo Server without doing anything fancy in my resolvers. I just assumed I’m getting N+1 issues but didn’t bother to optimize yet.

in short the separate engine process allows them to combine every findX call you make during one tick of the event loop into a single SQL query, following the dataloader pattern, so you don’t have to implement it yourself. i’m sure @nikolasburk can shed some more light if you’re interested.

Very interesting, thank you. Is there a way for me to monitor what Prisma is doing in my use case?

Re: Prisma – ORM for Node.js and TypeScript

#44
Oh also, Blitz.js is a nextjs fullstack framework that uses and autogenerates prisma code to work with.

Also FoalTS is a nice small framework for building rest endpoints with TypeScript, and recently landed @prisma support/documentation besides typeorm.

Just random fyi, hope someone finds it useful if they wan't to try prisma in a more batteries included package.

Re: Prisma – ORM for Node.js and TypeScript

#45
I am a noob in these matters which one is advised if one is to start a GraphQL API from the beginning

- use DBs that directly provide GraphQL endpoints such as Fauna, Upstash, etc. - use an ORM with more traditional DBs.

What are the pros and cons of each?

Re: Prisma – ORM for Node.js and TypeScript

#46
post #36

I know prism adds soo much more than just data access for your project, but for just replacing ORMs I think I really prefer the approach of https://github.com/adelsz/pgtyped where you have raw sql files / template literals and it will create types for parameters and results.

Pgtyped made sql+typescript a pleasure.

Re: Prisma – ORM for Node.js and TypeScript

#47
I'm sure a lot of hard work went into this, so I mean no offense here when I give my honest feelings.

The big differences between v1 and v2 make me uneasy. I am reminded of the constant API churn of React-Router, or the complete change from AngularJS to Angular. This approach makes me very hesitant to learn the library, because I am afraid of having the choice of painful upgrade or a dead dependency down the road.

I am also wary of the library being VC-funded, because I am afraid of what kinds of features will be held at ransom down the line once they need to start making money.

Re: Prisma – ORM for Node.js and TypeScript

#48

For those of you that want typed SQL queries check out pgtyped[1]. Using it in production and it is great for writing arbitrary SQL queries and getting full typescript support. [1] https://github.com/adelsz/pgtyped

pgtyped is awesome! We mention it along with similar tools like Slonik and Zapatos in our docs here: https://www.prisma.io/docs/concepts/overview/should-you-use-...

Re: Prisma – ORM for Node.js and TypeScript

#49

“ Application developers should care about data – not SQL” Anyone who has been bitten by an ORM generating inefficient SQL (and subsequent having to learn and care about SQL) knows the above not to be true.

This statement is certainly provocative (great that it was the first thing picked up here :D) but I'm happy to explain our rationale for this a bit more. SQL is an impressive technology and has stood the test of time! Yet, we claim that it's not the best tool for application developers who are paid to implement value-adding features for their organizations. SQL is complex, it's easy to shoot yourself in the foot with…

> SQL is an impressive technology and has stood the test of time! Yet, we claim that it's not the best tool for application developers who are paid to implement value-adding features for their organizations.

I'm not sure about that. We've recently switched from JavaScript based querying code to mostly raw SQL, and we've reduced our code to about 25% of what it was, and it's much simpler to understand than it was before.

> I see Prisma somewhat analogous to GraphQL on the frontend, where a similar claim could be: "Frontend developers should care about data, not REST endpoints".

I'm not sure about Prisma, but IMO that GraphQL model isn't great. Realistically (for performance, etc) it will make a difference where that data came from. Not for super simple queries, but super-simple queries are super simple to do with REST/SQL anyway. I also feel like this distinction between front-end and back-end developers isn't great.

The GraphQL approach also leads to deployment issue with non-web clients. e.g. it can take a day to get an iOS build released, and there is no way to force users of older clients to update, so this can take months. So fixing a bad query is difficult. With a proper backend you can just swap out the query.

Re: Prisma – ORM for Node.js and TypeScript

#50

I don't have much experience with node.js, so this question might sound silly. I don't see anything about database support in the blog post. Is Prisma enough to work with a PostgreSQL database from node.js? If not, what else am I missing?

Easy to miss in the long blog post:

> Prisma currently supports PostgreSQL, MySQL, SQLite, SQL Server (Preview). A connector for MongoDB is in the works, sign up for the Early Access program here (https://prisma103696.typeform.com/to/FriDuIeM).

Post reply on HN