How difficult is it to choose an ORM for Node.js? Or Node.js lacks a mature ORM

Mike picture Mike · Aug 4, 2020 · Viewed 7.1k times · Source

I have a production project to develop. It's an e-commerce site. My current stack:

  1. Node.js
  2. TypeScript
  3. PostgreSQL

Now I have to choose an ORM for this project. I think I have two options:

  1. TypeORM. I've used this ORM before. It's good and stable software, but TypeORM has had maintenance issues for a while. I'm not sure about the future of this ORM.
  2. MikroORM. TypeORM lacks some useful features like @Filters (scopes) and bulk subscribers, while MikroORM on the other hand has these features or alternatives (see filters and alternative to bulk subscribers). But MikroORM is less popular and relatively new. And many of MikroORM's features are still in alpha

Summary

ORM with lack of maintenance and features but stable or ORM with great maintenance, new features, but not battle-tested. Which option is better? Or maybe there are some alternatives?

Answer

Nikolay picture Nikolay · Aug 10, 2020

You can check Sequelize - https://sequelize.org, it has a TypeScript support, but the syntax is kind of ugly in my opinion. Among the three, Sequelize is the most mature ORM.

TypeORM is very nice, but has some major bugs like this - https://github.com/typeorm/typeorm/issues/3095. I came across to same or maybe similar problem related with saving one to many relations which i think is one of the most important features of every ORM and it must works properly.

I used MikroORM for a while - Again there are some minor problems which fortunately will be fixed in version 4. Overall, most of the features works properly and almost all of the problems that i had was resolved very quickly after reporting them on github.