Why is Prisma the exception to ORM hate?
I've never used an ORM, but for years have heard mostly negative things across various languages.
People throwing terms like anti-pattern etc.
Yet Prisma touts itself as the "Next-generation Node.js and TypeScript ORM" and people suddenly seem to be more lenient with the idea.
Random example:
https://twitter.com/matteocollina/status/1384900740754386946?lang=en
Why is this? What key criticism did it address to gain such popularity?
Matteo Collina (@matteocollina)
Prisma is the most interesting thing in database access happening in the Node.js space. Iâm usually against ORMs but I recommend you to check this out and evaluate.
https://t.co/VTVjIjDsdi
Likes
350
Twitter
8 Replies
Great question actually
The tl;dr is the separation of parts. It is a schema, client and query builder. The schema is a much clearer abstraction than the more abstracted models most ORMs make you commit to
The typescript "comes from the schema" whereas other orms have a schema generated from the code
^ Sachin's reply also has quite a bit of merit to this.
https://twitter.com/s4chinraja/status/1384977594932629504?t=NotonYPHm3fHsTMv7YiLqg&s=19
Sachin Raja (@s4chinraja)
@jsumners79 @matteocollina Key word here is care. They aren't saying you shouldn't know it, they're saying you shouldn't have to work with it so much.
Twitter
Very interesting, so my take away is:
db swapping aside ORMs have mostly been a QOL/DX argument afaik
It sounds like Typescript gave it more W's to add to the list then.
But TS isn't the only language with types and ORMs get hate else where too.
So I suppose the fact that web tech has a relatively common goal, as opposed to systems programming where the goal is a bit more nebulous, enables this fullstack solution (schema, client, builder).
A fullstack solution to a problem is not merely DX imo, but now offers architectural consistency and constancy where other fields find pain points
The schema can compile to rust as well
And golang
The schema is not in a specific language
That's the difference
I love Prisma because I hate migration files.
it sure can đ
Also don't forget python
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
My 2c coming form a former laravel dev. I for some reason decided to create the database first, then the ORM/schema after. It was just easier that way. That resulted in never using foreign keys, and indexes were a mess.
Using prisma, generating the schema first helped me a ton by forcing me to think of the data structure first instead of just winging it. It also set up the foreign keys and indexes a lot more efficiently than I could have done. It also allowed me to be more ânomadicâ in my dev environment. Like someone above said migration files are a pain to work with. With prisma you define the schema once, db push and youâre up to date.
TLDR: prisma is such a pleasure to work with, and itâs crud functions are simple enough and elegant.
My hot take: having a library that forms the raw queries for you instead of you making strings and an execute function makes the code 1000% more reusable. ORMs are useful in that regard. Prisma specifically because if you change the schema, you start getting TS errors if say you change a column from âtotal_billedâ to âtotalBilledâ in the schema. Building query strings wouldnât necessarily pick up that change.