Live data from Hacker News

Prisma – ORM for Node.js and TypeScript

prisma.io

71–80 of 260 posts

Re: Prisma – ORM for Node.js and TypeScript

#71

How are they going to make money?

We've explained this in the blog post here: https://www.prisma.io/blog/prisma-the-complete-orm-inw24qjea...

I think this quote summarizes our plans nicely: Prisma's vision is to democratize the custom data access layer used by companies like Facebook, Twitter and Airbnb and make it available to development teams and organizations of all sizes.

The open-source ORM we're launching today will of course remain open-source and we'll keep investing into it since it's be the foundation for the commercial tools that folks will be able to use on top.

Re: Prisma – ORM for Node.js and TypeScript

#72
post #61

Earlier quoted context omitted.

I have a feeling that does not work at all in non-trivial scenarios, e.g. if both composite keys and date range matching are required to resolve a reference.

Could you test this and get back to us with the results?

There are pretty extensive docs on how Prisma optimises n+1 queries: https://www.prisma.io/docs/guides/performance-and-optimizati...

Re: Prisma – ORM for Node.js and TypeScript

#73

How does it compare to MikroORM? I was researching different ORM options and almost wanted to give up until I discovered MikroORM, which is simply great. Edit: After quickly going through the intro, I prefer MikroORM, it's simpler.

I've tried Prisma, TypeORM and MikroORM and I'm certainly the most impressed with MikroORM.

It's simple and the use of identity map within a unit of work, tied to a request context (for example), is just brilliant.

The handling of relations (with configurable loading strategies) and other features such as Embeddables and Filters make it a real joy to use.

And if at any point I can't achieve something with MikroORM itself (which generally in my case is calling a PostgreSQL function), I can easily grab the underlying Query Builder from Knex.

It also has the tooling to generate a schema from your Entities, or generate Entities from an existing schema - so it's easy to get started on something new or existing.

Re: Prisma – ORM for Node.js and TypeScript

#74
post #43

Earlier quoted context omitted.

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

using `new PrismaClient({ log: ["query"] });` it'll log all the actual sql queries it's running, so you'll be able to see if queries are being combined

Awesome, thanks!

Turns out Prisma wasn’t optimizing my queries, I think it has to do with me not using the sub query API and instead querying tables seperately (e.g posts.findMany({ where: { owner: user } }))

Re: Prisma – ORM for Node.js and TypeScript

#75
post #59

I LOVE Prisma. I’ve used Django, SQLAlchemy, Sequelize, Knex, and TypeORM in the past. all had rough edges that continually frustrated me or didn’t provide the functionality i needed. Prisma is different. It’s absolutely got rough edges, but the extremely strong type safety makes Sequelize look like a joke. The query engine itself, written in rust, combines and optimizes queries inside every tick of the event loop so…

Laravel has Eloquent and it’s an absolute delight to use. I’ve used Rails and Django, and I always felt as if I was fighting the ORM, where as with Eloquent everything just seems natural.

I am a former PHP developer, absolutely loved Laravel and adored Eloquent as the ideal ORM. I switched to Node/JavaScript in 2015 and have been chasing a good ORM since, nothing could ever compare with Eloquent in Nodeland, I all but gave up and started building my own, in TypeScript to match Eloquent as much as possible.

Then Nikolas Burk reached out to me and did his absolute best to convert me, but I was stuck in my ways, it HAD to behave like Eloquent, or it was not good enough and that DSL layer? No thanks, I don't like it.

Started writing code for my own ORM when I was like "What the heck am I doing? this gets me nowhere" And messaged Nikolas back saying I was dropping everything and planned to give Prisma a real solid try.

I'm so glad I did. I LOVE it now. I consider it a part of my GOAT stack.

Re: Prisma – ORM for Node.js and TypeScript

#76

“ 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…

Oh don’t get me wrong - ORMs have their place and do enable higher agility. They do seem magical the first time you encounter them.

What I object to is the blanket “shouldn’t care about sql” statement because that’s what empowers people to use the ORM indiscriminately without understanding what’s under it (an understanding for which SQL is relevant) and then it’s the non-value-adding developers’ job to come in and untangle the mess, usually could have been avoided by dropping down one level, looking at the SQL that was generated (or maybe analyzing the query plan - again kind of hard if you don’t understand SQL) and realizing the ORM is doing something crazy.

Re: Prisma – ORM for Node.js and TypeScript

#77
I'm completely perplexed at some of the functionality that's absent in Prisma? I'm coming from the Rails/Django world for reference. Can anyone help me understand if I'm out in left field or does this technology only cover basic use cases?

  - No supported way to do a case-insensitive sorting.  https://github.com/prisma/prisma/issues/5068
  - Can’t sort by an aggregate value like user’s post count. https://github.com/prisma/prisma/issues/3821
  - Can’t control between inner/left join.
  - Can’t do subqueries.
  - Migration rollbacks are experimental maybe unsupported now? At least I only see mention in Github issues and not in the docs.
  - Transactions appear to expect a series of queries? It doesn’t look like you can execute any app code during a transaction?
  - No support for pessimistic row locking e.g. SELECT… FOR UPDATE ?
  - No way to mixin raw query partials like `where('name ILIKE ?')`. You either need to write the whole query raw or not.
  - Validations are done at the database level.
    - Complex validations seem tricky to write in this format
    - No built-in way to make clean user-facing validation messages.
    - You can’t check that a model instance is valid without just trying to insert it into the database
  - The official documented validation example has you connecting via psql and adding a constraint?
    - So following the offical example my validations aren’t documented in the codebase via a model or a migration? 
    - Also they don’t have a validation example documented if you’re using MySQL instead of Postgres?
  - Cascading deletes are handled the same way as validations. As in Prisma basically does nothing other than document how to implement it yourself outside of the library.
  - No model methods. I guess that's not a surprised because it's "not an ORM". A model really is just a data mapping? Anyways it seems like you would end up rolling your own wrapper around this and there's no recommendations on standardized architecture.
  - No callbacks. These have been controversial at times so are teams using Prisma writing something akin to "services" instead?
  - Syntax nitpick but one of these is vulnerable to a SQL injection and it seems really easy for a new developer to get mixed up?
    - prisma.$queryRaw(`SELECT \* FROM User WHERE email = ${email}`);
    - prisma.$queryRaw`SELECT \* FROM User WHERE email = ${email}`;
  - No way of batch loading like Active Records’s find_in_batches / find_each. All objects are just loaded into memory?
  - No way of hooking into queries for instrumentation. e.g. ActiveSupport::Notifications.subscribe
FYI - This is after fairly brief research. Not guaranteed 100% accurate.

Re: Prisma – ORM for Node.js and TypeScript

#79
post #61

Earlier quoted context omitted.

I have a feeling that does not work at all in non-trivial scenarios, e.g. if both composite keys and date range matching are required to resolve a reference.

Could you test this and get back to us with the results?

No need to test really - indeed more complicated cases are not covered by this yet. But happy to look at any Github issues with reproduction of cases that are not working, but could or should work to make your life better.

Re: Prisma – ORM for Node.js and TypeScript

#80
post #52

I LOVE Prisma. I’ve used Django, SQLAlchemy, Sequelize, Knex, and TypeORM in the past. all had rough edges that continually frustrated me or didn’t provide the functionality i needed. Prisma is different. It’s absolutely got rough edges, but the extremely strong type safety makes Sequelize look like a joke. The query engine itself, written in rust, combines and optimizes queries inside every tick of the event loop so…

To be fair, Sequelize makes itself look like a joke. I normally wouldn't call out an individual library to shit on, because I understand that a lot of work has gone into it. But I used it for years and it was always buggy. Sometimes options wouldn't work correctly because the authors liked to do that clever JavaScript thing where they write `foo = optional_thing || default_value` even for BOOLEAN options. I always ha…

No it's not. Even if they fixed all the bugs which I doubt the API design is bad.
Post reply on HN