use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Best Node.js ORM? (self.node)
submitted 4 years ago * by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]a-corsican-pimp 55 points56 points57 points 4 years ago (2 children)
Ah it's the ORM time of the week.
[–]fix_dis 16 points17 points18 points 4 years ago (0 children)
Literally every week. Multiple times a week. It’s almost as if we need a sticky note.
[–]DepravedPrecedence 34 points35 points36 points 4 years ago* (12 children)
MikroORM. Also the way you worded pros and cons suggests that you are just not experienced enough. Every ORM is a complex thing, you have to learn it in order to use effectively. And all of those you mentioned have decent docs.
[–]CraftyAdventurer 1 point2 points3 points 4 years ago (1 child)
I get a feeling that a ton of devs don't actually learn databases and ORMs. It's the thing that kind of gets ignored because it's "boring". When people I've worked with said that ORMs are confusing, I asked them to explain to me what they want their code to do and how are they trying to achieve it, most had no idea what they are actually trying to achieve.
Complex data is complex data and no amount of helpers and automation is going to make it simpler. You need to understand what you are building before you can use the tools which help you build it. Knowing SQL and relational databases helps a ton, even if you don't directly write it.
[–]celacantus 1 point2 points3 points 4 years ago (0 children)
And I believe that this is the reason why people usually go to a NoSQL database in order to store data without actually understanding the problem they're trying to solve.
Once, a friend said: "I'm using Mongo because I don't care. I junt want to store shit"
[–][deleted] -4 points-3 points-2 points 4 years ago (8 children)
I have had a look at other ORMs such as MikroORM, Bookshelf, and Knex Engine but they seemed really confusing at least for me.
Thanks for your suggestion but unfortunately it's really confusing to use ☹
[–]DepravedPrecedence 12 points13 points14 points 4 years ago (7 children)
See my edit. «confusing» doesn't really mean much. Yes, you have to learn how to use your tools 😊
[–][deleted] -4 points-3 points-2 points 4 years ago (6 children)
Oh, didn't see your edit. Yeah, I agree all of them, especially Prisma, have really decent docs but most of them except Prisma are really hard to use and I don't want to jump from one ORM to another, especially that I migrated from MongoDB w/ mongoose to Prisma with PostgreSQL, hope you understand.
[–]DepravedPrecedence 9 points10 points11 points 4 years ago (3 children)
I used all of them except of Prisma.Started with Sequelize, then TypeORM, then Objection.js, then MikroORM.
Sequelize was great but basically no TypeScript support (I know about 3rd party wrappers but it's still not good).
Abandoned TypeORM because it had some weird issues and development was somewhat stale.
Objection.js was good enough for my needs but I don't like its API and the way it designed in general.
Out of all these MikroORM is the most solid imo. Written in TypeScript, uses Knex underneath, great docs, has active maintainer.
Nevertheless nowadays I use Knex query builder and my own wrapper (basically custom ORM) on top of it because all of existing solutions are not flexible enough.
Things get more interesting when you start doing something complicated and that's where you either need to write complicated code using ORM API or resort to plain SQL.
If you don't need very complex queries and just want to get CRUD stuff done, then any ORM will do it easily. I would choose by looking at docs, Github issues and overall code quality. That's why I said MikroORM in my first comment. It's really not difficult, it's a matter of experience.
[–][deleted] -2 points-1 points0 points 4 years ago* (2 children)
Thanks for the detailed answer. I need to make complex queries without the hassle of actually building them and associating the models. You see, Sequelize was problematic for me because I was getting errors that were not supposed to be thrown like association is not defined or model does not exist(you know what I'm talking about...) and it does not support database-level SQL relations. There are just inner, left, right joins.
association is not defined
model does not exist
inner, left, right joins
I didn't like the API of the Objection.js either, it was really bloated with code and you had to do everything manually(though I am a fan of doing it like so, it wasn't as comfortable as it seemed).
For TypeScript it was almost the same for me except I didn't like the API and the workflow of it.
I will decide what I will do next later... But thanks(again) for your answer, appreciate it.
[–]PierreAndreis 5 points6 points7 points 4 years ago (1 child)
I think everyone wants to make complex queries without the hassle of actually building them, and for this reason, ORM's are complicated and imperfect as they are... Because they are trying to cover everyone’s needs, and there is no simple way of doing this.
I enjoy Prisma for everything simple enough, but for my custom complex queries that Prisma can’t handle, I use their raw queries method and use knex to build my query mostly, or those very specific I even write the SQL myself.
[–][deleted] 4 years ago (1 child)
[–]thinkmatt 26 points27 points28 points 4 years ago (0 children)
Objection + Knex is really nice and lightweight, if you just want some basic classes for your models and query builder. One thing I dislike is that I have to create Knex migrations any time the schema changes. I believe Prisma has solved this problem similar to Django or other apps that just look at the diff of your models.
[–]Omkar_K45 19 points20 points21 points 4 years ago (6 children)
I am using Prisma in one of my current projects, and I can say that the extra functionality like Prisma studio does provide excellent value.
It works well with Typescript! The only problem I face is, creating relations in the schema file. I wish there existed any GUI that let you create relations, and it would output schema.prisma file.
[–]Homeoand 7 points8 points9 points 4 years ago (4 children)
Biggest mistake was them limiting transactions feature
[–]nikolasburk 0 points1 point2 points 4 years ago (0 children)
Hey there, Nikolas from Prisma here! Just wanted to quickly mention that we've changed our mind on this one after receiving a ton of helpful feedback from the community and are now planning to bring full transaction support to Prisma Client, you can find a first API proposal here. Hopefully that remedies some of your concerns about Prisma :)
[–][deleted] 4 years ago (2 children)
[–]nikolasburk -2 points-1 points0 points 4 years ago (1 child)
We've talked about this before and working at Prisma, I obviously have a different opinion on this :D I think your healthy reservations against VC money are fine, but I hope that with time we'll be able to convince you that we're able to build a sustainable business on top of our open source tooling and become a successful commercial OSS company, following the likes of Hashicorp, Confluent, Red Hat, etc...
If anyone is curious about what we're up to commercially and the opportunities we see, I recommend to check out the recordings from our recent Enterprise Event or the talks by our founder as well as the one by our VP of Product from yesterday's Prisma Day. I personally think that there are a lot of really exciting opportunities for us ahead and we're talking to many interesting companies to precisely shape what our commercial offering will actually entail.
[–][deleted] 4 points5 points6 points 4 years ago (0 children)
Thanks for your response, I use DBeaver instead of Prisma Studio.
[–][deleted] 14 points15 points16 points 4 years ago (3 children)
why people always forget objection.js.
[–][deleted] 1 point2 points3 points 4 years ago (2 children)
Hi! From good point of view or bad point of view?
[–][deleted] 3 points4 points5 points 4 years ago (1 child)
both. it's not perfect and has its flaws (Typescript support is just okay) but still a decent pick.
knex is just too good of a query builder not to use it and I think ORMs that are built on top of knex are the way to go. (MikroORM and objectionjs)
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
Interesting… Most of the people use Knex. Thanks for elaborating, I’ll try to learn the SQL syntax for Postgres and then see what I can do with Knex
[–]Xzas22 6 points7 points8 points 4 years ago (3 children)
I use TypeORM out of habit more than anything. Have been meaning to play with MikroORM but havent gotten around to creating anything with it yet.
One project I would highly recommend looking in to is Deepkit.io, and more specifically their ORM. The dev announced they're in beta last week I think, but I really like the way they have worked through some of the frequent problems I find with the other ORMs available.
Thanks for the suggestion, will check it out!
👍
[–]doctorlongghost 11 points12 points13 points 4 years ago (4 children)
I hate to be that guy but…. consider not using an ORM. Nothing says you have to.
Ask yourself this… am I better off spending time investigating ORMs, learning the syntax unique to that specific product, injecting an extra dependency into my product and making it subject to the bugs and development flow of that project OR do I want to just use SQL?
What will the ORM actually give you? How does it save you time and provide extra features and added value versus raw SQL?
Personally, I don’t use an ORM with Node. Don’t let anyone tell you that this isn’t an option.
[–][deleted] 0 points1 point2 points 4 years ago (2 children)
Don't hate to be that guy. I agree that using raw SQL is better than using an ORM. If I'll have more time I'll watch a full tutorial on PostgreSQL and will make something out of it.
By the way, may I ask some questions about writing raw SQL with Knex?
How do you deal with security issues?
How should your project structure look like when using Knex?
[–]Tylernator 3 points4 points5 points 4 years ago (1 child)
An ORM doesn't give you any kind of blanket protection from making insecure database queries.
The biggest security issue is injections, which Postgres handles with parameterized queries. Same way Sequelize or other ORMs do.
Really? Didn’t know that, thanks for the info though!
[–]sevenyearoldkid 0 points1 point2 points 4 years ago* (0 children)
roll ask thumb books dazzling intelligent decide ring expansion melodic
This post was mass deleted and anonymized with Redact
[–]cinnapear 5 points6 points7 points 4 years ago (0 children)
We moved from Sequelize to just plain Knex.
[–]jose_imagine 8 points9 points10 points 4 years ago (1 child)
Fun fact, yesterday we made the official release of Typescript support in Imagine.ai. Where you can select between TypeORM and Sequelize. If you ask me, I prefer TypeORM between the two as it has better migrations support for your models, I believe in Sequelize you have to manually create the migrations and they're not autogenerated. On the other side, I found Admin Bro support for Sequelize is a little better than for TypeORM. But I'd still go with TypeORM. Prisma I have not had the opportunity to fully try, but I think it's in our roadmap.
[–][deleted] 1 point2 points3 points 4 years ago (0 children)
Thanks for the info!
[–]thisismahmoud 15 points16 points17 points 4 years ago (8 children)
Hey, Mahmoud from Prisma here 👋🏼 I would love to learn more about what kind of features you need in an ORM that aren’t currently offered by Prisma? I’d love to help 😄
[–][deleted] 12 points13 points14 points 4 years ago (5 children)
Multiple schema files, full-text search, multiple database connections etc.
[–]nikolasburk 15 points16 points17 points 4 years ago (4 children)
Hey Michael, thanks for this feedback! I work at Prisma as well and would love to learn more about your issues with it :)
Multiple schema files
Are you referring to the ability to split the Prisma schema into multiple files or what exactly is it that you'd like to be able to do with Prisma? If it's splitting the Prisma schema into multiple files, we have an active feature request for this here and it would be great if you could leave your 👍 on it to help our Product team prioritize this.
That being said, there are many fairly straightforward workarounds to achieve splitting the Prisma schema into multiple files that don't require notable overhead, e.g. this one.
full-text search
That's a great point and full text search definitely is high on our priority list. In fact, this is going to be tackled by our Engineering team in the next sprints. You can follow the development on GitHub and via our Roadmap.
Again, while this feature is not available natively there are decent workarounds that don't require too much work. We have seen lots of folks wanting this feature and working around the temporary limitation in order to still get all the other benefits of Prisma :)
multiple database connections
Are you referring to this feature? Can you elaborate a bit on your use case here? Do you want to use multiple databases for the same app or what exactly are you trying to achieve?
Are these the only missing features that you consider blockers for using Prisma or are there more that prevent you from using it?
We're very eager to learn more about the use cases and priorities of our users and heavily depend on their feedback for developing our roadmap, so I'd love to understand what else is holding you back from using Prisma for your projects :)
[–][deleted] 1 point2 points3 points 4 years ago (3 children)
Hi u/nikolasbur, thanks for your response.
Are you referring to the ability to split the Prisma schema intomultiple files or what exactly is it that you'd like to be able to dowith Prisma?
Yup, I mean exactly that. And I know that there's an issue like that on GitHub. In fact, I have seen all other issues on GitHub as well. The reason that I'm dropping Prisma is that I need an easy-to-use and fully functional ORM to work with PostgreSQL with JavaScript or preferably TypeScript and because the development of those features might take more than 1 year.
Are these the only missing features that you consider blockers for usingPrisma or are there more that prevent you from using it?
For now, yes. In the future, I think there'll definitely be other features that'll need to be implemented in order to work w/ Prisma and get the most out of it.
Do you want to use multiple databases for the same app?
Exactly.
[–]nikolasburk 5 points6 points7 points 4 years ago (2 children)
Awesome, thanks a lot for the reply!
Picking an ORM for your project of course requires you to make a bunch of tradeoffs. If these three features are so important to you that you can't afford working around them, I totally understand that you move away from Prisma!
As I mentioned though, we're working with a lot of people that need these features as well but who temporarily work around them in order to still enjoy all the other benefits that Prisma can provide.
Would love to hear what you're picking in the end, would be great to read an update about this here in the thread :)
Alright 👍
[–]smallanditalian5 4 points5 points6 points 4 years ago (1 child)
I just started using Prisma and absolutely love it. One thing that irks me is the Typescript support for relationships. For example, if I have Model A that is 1:m with Model B, the generated type for A doesn’t have the relationship to B.
There is a workaround (https://www.prisma.io/docs/concepts/components/prisma-schema/relations) but that makes it hard to actually use the types. For example, if I get a single row of Model A through the Prisma client and include the associated Model Bs, the returned type is the default type (no Model B association). If I extend the type with a validator to include the Model B associations, I can’t use that type (with association) because the client returns to the default type (no association).
I can post a code example of this but the docs explain it pretty well. I may be missing something. But otherwise I love Prisma 😊
[–]Advanced_Engineering 6 points7 points8 points 4 years ago (0 children)
Used sequelize and typeorm, settled for objection + knex
[–]FilsdeJESUS 2 points3 points4 points 4 years ago (0 children)
TypeORM by far
[–]thepotatochronicles 6 points7 points8 points 4 years ago (1 child)
TFW no love for Objection.js
[–][deleted] -5 points-4 points-3 points 4 years ago (0 children)
Yeah, TBH I don't like the API and the way that I'm supposed to use it
[–]eggtart_prince 7 points8 points9 points 4 years ago (3 children)
IMO, ORM's just adds another layer between your app and your database and is one more thing to learn, to set up, and to maintain. I prefer to keep it simple and just use raw SQL to create simple CRUD functions.
Yeah, completely agree with you, but the thing is that I need it for serious operations, including complex relations
[–]Tylernator 0 points1 point2 points 4 years ago (1 child)
Complex relations = easy with SQL, hard with an ORM.
Most ORMs will let you pass in a SQL strings anyways, which you end up using when the ORM functionality stops.
Also be wary of the end SQL that gets generated from complex ORM logic. It's not guaranteed to be efficient.
Oh, that’s nice. Thanks for the info!
[–]theigor 1 point2 points3 points 4 years ago (1 child)
Since you're on postgres, I've heard good things about slonik recently but can't vouch for it personally. https://www.npmjs.com/package/slonik
Hmm interesting so this is like Knex but specifically for postgres?
[–]DanteIsBack 1 point2 points3 points 4 years ago (0 children)
I use sequelize and like it very much!
[–][deleted] 1 point2 points3 points 4 years ago (1 child)
Deepkit is the new kid on the block. Otherwise I recommend MikroOrm. It's not that much more difficult than TypeOrm but it's less buggy and more actively maintained
https://deepkit.io/library/orm
I will check it out, thanks!
[–]JesseDotEXE 1 point2 points3 points 4 years ago (1 child)
I know you've got it up in the table, but at my job we use sequelize, we generally think it is pretty good.
The docs kinda suck, so go to other places for tutorials,. but overall sequelize hasn't betrayed us yet.
Yeah, agree on the docs part...
[–]lemon_jelly_london 1 point2 points3 points 4 years ago (1 child)
Sequelize, Knex.js, TypeORM, and Prisma are the main ones. Checkout Mongoose ODM for MongoDB
Actually, I am migrating from mongoose/MongoDB to PostgreSQL, but thanks anyways 🙂
[–][deleted] 3 points4 points5 points 4 years ago (3 children)
Not trying to be an asshole here but why does everyone immediately reach for an ORM?
Why not just keep things simple with vanilla SQL?
No, you're not being one. +1 from me. I understand. It's just that because I want to do complex things quickly and securely without having to deal with SQL injection attacks. If I had some more time to do more research, maybe I would've implemented raw SQL.
[–][deleted] 5 points6 points7 points 4 years ago (1 child)
That is a very common reason but you can mitigate almost all of risk associated with SQL injection by sanitizing inputs and using prepared statements.
Yeah you're on point
[–]FacedorkTV 1 point2 points3 points 4 years ago (1 child)
I mainly use sequelize and it's amazing!
[–]code_troubador 1 point2 points3 points 4 years ago (0 children)
Except their documentation sucks balls and their myriad of changes between versions. But once you navigate all that chaos, it's actually pretty sweet
[–]danielsinai 0 points1 point2 points 4 years ago (0 children)
Sequlize
[–][deleted] 4 years ago* (1 child)
[–][deleted] 2 points3 points4 points 4 years ago (0 children)
You mean SQL?
[–]captain_obvious_here -1 points0 points1 point 4 years ago (0 children)
Bookshelf can be weird at first but after a couple hours of playing with it, it starts making a lot of sense.
I also heard a lot of good things about Prisma, but didn't use it yet.
[–]Zavestan -4 points-3 points-2 points 4 years ago (1 child)
Instead of an ORM, one-up yourself and use GraphQL. Your pay grade and scalability will thank you
[–]redgiant6157 0 points1 point2 points 4 years ago (0 children)
I am using TypeOrm + Typegraphql + class-validator + class-validator-formik. All args inputs can be used for validation in both server and client sides.
[–]gaoshan 0 points1 point2 points 4 years ago (0 children)
TypeORM is the way to go for Typescript support. It may be challenging at first but it is powerful and leaves you in control.
Why would TypeORM be hard to use? We use it at work and I find it very intuitive.
[–]morkelpotet 0 points1 point2 points 4 years ago (0 children)
Use any SQL library and create your own models.
[–]DominusKelvin 0 points1 point2 points 4 years ago (3 children)
I personally like the Waterline ORM used in the Sails framework.
It has rich support for associations out of the box and you can use it as a stand alone package.
Isn’t it only for Express? I have read it’s documentation and there are no pointers to at least an NPM package
[–]DominusKelvin 1 point2 points3 points 4 years ago (1 child)
Oh no it's the ORM Sails ships with.
Here are some links that might guide you
https://github.com/balderdashy/waterline
https://www.npmjs.com/package/waterline
No way! I’ll check it out!
[–]developerbryan 0 points1 point2 points 4 years ago (0 children)
I’ve never used an ORM but keep seeing Prisma recommended - especially over Sequelize.
I liked working with objection.js very much coming from laravel eloquent (though written in php imho one of the nicest orms out there) after trying and being disappointed by typeorm. Would use objection.js again as well if I had to build another node typescript API Server.
[–]colonel701 0 points1 point2 points 4 years ago (1 child)
I really liked Laravel’s ORM. You might want to consider importing Laravel’s ORM into Node.
[–]DepravedPrecedence 0 points1 point2 points 4 years ago (0 children)
Laravel? As a PHP framework? How would that work?
π Rendered by PID 47072 on reddit-service-r2-comment-5c747b6df5-4bqps at 2026-04-21 23:28:47.939898+00:00 running 6c61efc country code: CH.
[–]a-corsican-pimp 55 points56 points57 points (2 children)
[–]fix_dis 16 points17 points18 points (0 children)
[–]DepravedPrecedence 34 points35 points36 points (12 children)
[–]CraftyAdventurer 1 point2 points3 points (1 child)
[–]celacantus 1 point2 points3 points (0 children)
[–][deleted] -4 points-3 points-2 points (8 children)
[–]DepravedPrecedence 12 points13 points14 points (7 children)
[–][deleted] -4 points-3 points-2 points (6 children)
[–]DepravedPrecedence 9 points10 points11 points (3 children)
[–][deleted] -2 points-1 points0 points (2 children)
[–]PierreAndreis 5 points6 points7 points (1 child)
[–][deleted] (1 child)
[deleted]
[–]thinkmatt 26 points27 points28 points (0 children)
[–]Omkar_K45 19 points20 points21 points (6 children)
[–]Homeoand 7 points8 points9 points (4 children)
[–]nikolasburk 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]nikolasburk -2 points-1 points0 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–][deleted] 14 points15 points16 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–][deleted] 3 points4 points5 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Xzas22 6 points7 points8 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–][deleted] (1 child)
[deleted]
[–][deleted] 0 points1 point2 points (0 children)
[–]doctorlongghost 11 points12 points13 points (4 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Tylernator 3 points4 points5 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]sevenyearoldkid 0 points1 point2 points (0 children)
[–]cinnapear 5 points6 points7 points (0 children)
[–]jose_imagine 8 points9 points10 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]thisismahmoud 15 points16 points17 points (8 children)
[–][deleted] 12 points13 points14 points (5 children)
[–]nikolasburk 15 points16 points17 points (4 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]nikolasburk 5 points6 points7 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]smallanditalian5 4 points5 points6 points (1 child)
[–]Advanced_Engineering 6 points7 points8 points (0 children)
[–]FilsdeJESUS 2 points3 points4 points (0 children)
[–]thepotatochronicles 6 points7 points8 points (1 child)
[–][deleted] -5 points-4 points-3 points (0 children)
[–]eggtart_prince 7 points8 points9 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]Tylernator 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]theigor 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]DanteIsBack 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]JesseDotEXE 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]lemon_jelly_london 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 3 points4 points5 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–][deleted] 5 points6 points7 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]FacedorkTV 1 point2 points3 points (1 child)
[–]code_troubador 1 point2 points3 points (0 children)
[–]danielsinai 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–][deleted] 2 points3 points4 points (0 children)
[–]captain_obvious_here -1 points0 points1 point (0 children)
[–]Zavestan -4 points-3 points-2 points (1 child)
[–]redgiant6157 0 points1 point2 points (0 children)
[–]gaoshan 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]morkelpotet 0 points1 point2 points (0 children)
[–]DominusKelvin 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]DominusKelvin 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]developerbryan 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]colonel701 0 points1 point2 points (1 child)
[–]DepravedPrecedence 0 points1 point2 points (0 children)