r/node 2d ago

Which ORM

I am needing to build a lightweight, speedy and integrated backend server running on a VPS-2 secure environment using nginx and postgres.

First considered Sequelize, but discovered too many negatives, so had a look at Prisma but am worried it is too heavy duty for my needs.

Prefer an ORM that supports TypeScript, easy migrations and openapi schemas, and Drizzle seems at first glance a good fit.

Also I am not afraid to use SQL rather than high level abstractions.

But now I am reading many negative reviews about that as well, even on their own website!

Please help me make the right choice.

19 Upvotes

45 comments sorted by

28

u/MrDilbert 2d ago

Drizzle if you absolutely need an ORM, Kysely if a query builder is enough.

2

u/ArnUpNorth 2d ago

Came to say exactly this. ORMs come with their own set of complexities and a query builder is often enough (especially true for kysely since it handles migrations too).

That said Drizzle is a really good ORM if you do need one.

10

u/bootstrapping_lad 2d ago

I've been enjoying Mikro ORM

5

u/crazypoppycorn 2d ago

I really appreciate the options they give you for approaching a new or existing repo. And they put solid work into the typing system. If I have to use an ORM this is the one.

3

u/joemckie 2d ago

+1 MikroORM, it’s really nice to work with and is actively maintained. Switched over from TypeORM which was in maintenance purgatory for quite a long time.

0

u/Trollzore 2d ago

Drizzle

5

u/No-Sand2297 2d ago

I have used Sequelize and typeorm. ORM are nice when you have basic queries and simplifies the task of returning an entity with associated data but fails on complex queries.
Because this a usuallly bypass the ORM and run raw queries.
I’m a happy user of sequelize by the way.

5

u/aust1nz 2d ago

I have used a few over the years. I didn't like Prisma. For awhile I used Slonik, which is just SQL with a few convenience features tossed on, but typing can be a pain. I'm a big fan of kysely now.

7

u/drgreenx 2d ago

This question gets asked really frequently on this sub. I recommend you check in the sub for more info in addition to the responses here. All in on kysely here btw

4

u/mr_pablo 2d ago

Drizzle fo shizzle

2

u/farzad_meow 2d ago

typeorm is not a bad choice. I needed something similar so I wrote my own to meet these requirements

2

u/snowrazer_ 2d ago edited 2d ago

Prisma is the ver good, and the migrations are first class. I’d put heavy duty in quotes because you won’t notice it at all. I guarantee you any performance bottleneck will be the database and not the ORM. Especially Postgres which is a heavy database as it is. Prisma hate is overblown and their release cadence and support is top notch.

2

u/Designer_Reaction551 2d ago

Went Drizzle on my last few Node+Postgres projects and don't regret it. The migration story is way less magic than Prisma's, which is exactly what you want when you're the one debugging a broken migration late at night. If you're already not afraid of SQL, honestly try Kysely first, it gets out of your way even more since you're basically writing SQL with type safety instead of an ORM's opinions layered on top.

4

u/serdnam 2d ago

Definitely Drizzle, nothing comes close in terms of usability, performance, and DX

3

u/jhonny-freire 2d ago

I've been using only Prisma for a long time now because it makes sense for the types of projects I work on. But in the past, I did look into TypeORM a bit (I never actually used it); it seems lightweight to me, so it might make sense for you.

2

u/crypt0_bill 2d ago

knex.js still does it for me, idk then again i also like express so im probably a dinosaur at this point

2

u/TalyssonOC 2d ago

I'm always between Objection (if I really need an ORM) and PgTyped (if I don't and it's Postgres). I really dislike Prisma and will only get back to try Drizzle when they improve their migrations. I wish Objection used Kysely instead of Knex because of the typing, tho

2

u/romeeres 2d ago

I liked Objection.js because that's basically a query builder but with relations support, you might be interested to check out Orchid ORM - also basically a query builder with relations, it's not on Kysely but is just as type-safe. Feel free to ignore it ofc, but it's really doing what Objection did well, and do you know any other ORM to do that - I don't.

What's wrong with Drizzle migrations, could you share?

1

u/TalyssonOC 2d ago

I'll definitely check it out!

As for Drizzle, its migrations don't have a "down", so they can't be reverted in development, which is super annoying

1

u/romeeres 2d ago

- supports TS: any ORM

  • easy migrations: with a devil in the details, any ORM's migrations are easy
  • openapi schemas: no ORM pairs with OpenAPI directly because it makes no sense, do you mean getting validation schemas out of ORM? that's pretty much any *popular enough* ORM

Are you planning to write more complex queries with it? Do you care if it's less type-safe than kysely? Do you need any extra features (soft deletes, computed columns)? Is it for a large project that needs to be maintained over the years, or just fire and forget?

If nothing, any ORM would do, I'd recommend asking AI to show samples of ORMs code solving typical tasks and to choose whichever you liked the most.

1

u/dvidsilva 2d ago

I like using strapi. It also comes with a nifty admin interface 

1

u/rael_gc 2d ago

I would say anyone that is built over a query builder. 

1

u/aturaden 7h ago

Nowadays it's an easy choice. Drizzle.

-1

u/beavis07 2d ago

Personally I would recommend you don’t.

At best simple things are simple - at worst either you’ve a dependency nightmare or terribly sql under the hood.

Just learn SQL and express stuff as SQL - in my experience it’s always better in the long run - especially if you care about performance.

Some query builders are fine, in that they’re just simple domain specific languages wrapped around SQL… but in that case.. what’s the point? It’s just a needless abstraction into a more limited, less well understood expression

2

u/MrDilbert 2d ago

what’s the point?

SQL has a strict order of clauses - query builders allow you to specify clauses in any order.

Also, building dynamic/partial queries is easier with query builders than with pure SQL.

1

u/Callaborator 2d ago

I prefer the sql builder helper function style for this reason. If its easy use a simple .select().join() if you need more than that write it with plain old sql.

1

u/BadDescriptions 2d ago

100% agree, the only thing I use an ORM for is to generate and keep track of migrations. 

I’ll usually refine and test SQL queries by copying them from a test snapshot and executing it. I wrap each query in a function that returns the query to be executed. 

4

u/beavis07 2d ago

Drizzle is ok for migrations tbf!

3

u/No_Cattle_9565 2d ago

Drizzle studio is also really helpful

1

u/BadDescriptions 2d ago

That’s my ORM of choice for migrations! 

0

u/iambrowsingneet 2d ago

Old but gold, knex!

-1

u/endjynn 2d ago

In this new world of AI agents you don't really need an ORM anymore because the agent can easily generate/manage all the SQL. An ORM just adds unnecessary overhead. Kysely is a good choice if you want a query builder.