rit-sse / node-api

💯 The SSE New and Improved Unified API
https://sse.rit.edu/api/v2
MIT License
8 stars 9 forks source link

Update sequelize to v5 #110

Closed gavrielrh closed 4 years ago

gavrielrh commented 4 years ago

Updates to following package(s) (fixing vulnerabilities): sequelize ^3.19.0 -> ^5.21.5 pg ^4.4.1 -> ^7.0.0

There are breaking changes between v3 and v4: https://sequelize.org/v4/manual/tutorial/upgrade-to-v4.html

Sequelize models are now ES6 classes, so instanceMethods have been moved out of options. They are now set via prototype
options.order now only allows arrays / sequelize methods, not string values
`afterUpdate` is now within the hooks options, and not a direct prototype of a model

And breaking changes between v4 and v5: https://sequelize.org/master/manual/upgrade-to-v5.html

Operator aliases are no longer allowed by default (`$lt` must now be `[Op.lt]`)
`findById` is now `findByPk`
`updateAttributes` is now `update`

The instance methods on sequelize models must use the classic function syntax over arrow function syntax, since arrow functions (=>) will lexically bind this to undefined based on the scope, whereas function will dynamically bind this.

The mocha tests began failing on upgrading to v5, as the version of pg we were using was too outdated for sequelize v5, so that has been updated as well.