You are currently viewing Moving from Waterline to Sequelize

Moving from Waterline to Sequelize

  • Post published:January 21, 2020

By the time we were working on project the backend structure was not in a good shape. As the project was live so we were not supposed to do drastic changes in backend structure. Previously it was using Sails Framework with Waterline ORM. Things were complicated; there were enormous raw queries that were written on the backend. Model associations was no used effectively. As the time goes and project gets bigger the API response time was getting increased. So, we thought to revamp our backend. After doing some analysis we figured out that, we should get rid from sails as it is a wrapper over express. So, why don’t use express simply? Express is core framework for backend and it provides all the features. According to the StackShare community, ExpressJS has a broader approval, being mentioned in 843 company stacks and 760 developers stacks; compared to Sails.js, which is listed in 32 company stacks and 12 developer stacks.

We decided to switch to Express core with Sequelize ORM rather than using Sails.js with Waterline ORM. Besides Sequelize framework is more popular than the Waterline. It got bigger community good support and awesome features. Here’s the analysis of Waterline vs Sequelize.

Moving from Waterline to Sequelize 1

According to google trends the usage of Sequelize ORM is too much higher than the Waterline ORM because It’s the most popular ORM that is being used at the moment. Sequelize is far ahead than Waterline when it comes to performance, usage, community, developers and support .

Waterline has no built-in migration system. Tables are created automatically. There two settings though: one where the tables are created based on the model’s definitions (the tables are re-created when the models change), the second (called “safe”) where nothing is done automatically. This is the mode you want to use in production.

Sequelize  has a built-in migration system (up, down, create…). There is also a mode where tables are created automatically but it is safer than waterline’s. Tables are created only if they do not exist (you can force sequelize to re-create tables when your models change, therefore making it work like waterline).