by John Vandivier
NOTE: May 2018: Read From TypeORM to LoopBack: A Retrospective for an updated perspective!
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
What is an ORM and Why is it so Important?
ORM solutions are useful to facilitate data-driven API development. Users have concrete needs which drive the data model of an application. In legacy development, this data architecture is typically implemented and version controlled using database scripts such as SQL scripts. A separate library is then used for the server application to execute CRUD actions on the database.
ORMs work as a high-level API to execute CRUD, and these days quality ORMs also allow us to initialize the data through code. Complex data manipulation, cleaning and so on, is often easier in code. While dedicated Extract, Transform and Load (ETL) tools exist, the same ETL tasks can be easily implemented in ORM.
Finally, code-oriented data control also allows a system to implement data usage at run time or in the build process, and flexibly adapt usage during the development process as needed.
To restate, ORMs improve developer productivity by providing a high-level API, in a single language, with functionality that would traditionally require several different tools and skill sets. Fewer skill needs, tool needs, and hours required facilitates project margin. Unforeseen requirements and project timeline are better prepared with flexible build and run-time data configuration.
Preferred ORM Capabilities
Node natively supports file system operations, so Content Management System data requirements amount to a preference for wide-ranging database support. In total, the following requirements are considered:
- Support for Mongo and MySQL, with preference to support of additional options
- Integrate with Webpack
- Integrate with Express
- Minimal hit to performance at run time
- Intuitive syntax
- Extra features
- High Github star to issue ratio
- Actively maintained with no build failures or deprecated dependencies
The Candidates and Results
Each candidate received a score between 0 and 10 for each preferred capability. A score of 5 means acceptable. The average for a column may be more or less than 5. For example, an ORM with support for multiple NoSQL databases and no support for any SQL database will receive a score between 2 and 4. 0 indicates the complete lack of a feature.
The totals reflect the overall usefulness of each solution. The top 5 results were:
A combination of project-specific needs, omitted factors, and personal preference lead to the top 3 picks.
Waterline is heavily integrated into the Sails framework and Mongoose only supports MongoDB.
Sequelize and NodeORM2 are restricted to SQL and they lack API generation.
Due to the TypeScript syntax, TypeORM integrates nicely with an Angular project.
As a developer, I recommend prototyping more than one top solution to identify the real winner. The top 3 solutions, which are all prototyping candidates, include:
I submitted this information to other developers on the project, and as a team we decided to try out TypeORM first. Check back later for the retrospective!
What do you think of this result? Leave a comment or contribute you thoughts to this Slant comparison.