Which ORM is best for nodejs?

Viewed 23760

I am nodejs developer. I want to create online shop website with api for mobile applications also (android, ios). But I am not decide which ORM can be used for my requests. I am using postgresql database.

Request:

  1. Fast connections, responses (fastest for all)
  2. Clean understanding code
  3. Secure

I think below ORM are good:

  1. express + sequelize
  2. loopback ......

Which ORM or solution is best for my requests?

7 Answers

Checkout Typeorm

TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8). Its goal is to always support the latest JavaScript features and provide additional features that help you to develop any kind of application that uses databases - from small applications with a few tables to large scale enterprise applications with multiple databases.

TypeORM supports both Active Record and Data Mapper patterns, unlike all other JavaScript ORMs currently in existence, which means you can write high quality, loosely coupled, scalable, maintainable applications the most productive way.

I am using Typeorm with Postgresql. I've been trying sequelize too, but finally I decided to use typeorm because the code is clean and maintainable, your code is elegant and easy to read, support multiple DBMs, decoratos, it's a great ORM. I am using it with Typescript and Express. I hope you can actually consider using it.

I prefer Sequelize ORM as it has a better query syntax in my opinion and when you add something like sequelizejs-decorators you get the nicety of decorators to define your tables with the better query syntax.

A young alternative to typeorm, that I am trying and seems good, is mikro-orm.

ObjectionJS is a good one in my opinion. It uses KnexJS SQL query builder. Both are compatible with TypeScript. Knex uses migration pattern so you can rollback to your previous state with single command. It's migration system is more like Laravel's famous Eloquent.

I'd check out Prisma – a type-safe ORM for Node.js and TypeScript.

Since you mentioned "Clean understanding code", it's worth mentioning that Prisma uses the Prisma schema as a declarative source of truth for your database schema and generating the actual database access code. This approach has the advantage of not needing to define model classes, thereby reducing the amount of code you write.

For more information on Prisma's approach to ORMs, check this article out.

Disclaimer: I am the author of this library.

Kiss-ORM is an ORM for NodeJS and Typescript. It uses a data-mapper pattern, and it's core philosophy is to help you enough but at the same time not to "get in the middle".

It allows you to write and concatenate SQL queries in a secure way, because SQL is just fine and very powerful.

Since it does not add much abstraction layers between your code and the database, you can get the same performance and customization capabilities as directly using a package like node-postgres.

Related