I need to use Node.js, but it doesn't have a good ORM for MySQL. So I'm planning on using SQLAlchemy to define my schema. And then use node-mysql to do low-level queries (of course, I wouldn't be able to use SQLAlchemy's query language coz it's in python.)
What do you guys think?
sequelize seems to be the best one...but it doesn't seem that many people are using it. Also, what about migrations? How would I handle that?
node-orm doesn't seem very active either.
Thoughts on this?
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).
Different database systems access data in myriad ways, and ORM helps you maintain objects even when the sources and apps they access change over time. ORM is commonly used to streamline the migration of data between databases. Before we get to the reasons why you shouldn't use ORM with Node.
js supports all kinds of databases no matter if it is a relational database or NoSQL database. However, NoSQL databases like MongoDb are the best fit with Node. js. To access the database from Node.
Sequelize is pretty good ORM for MySQL and has excellent documentation. You can use node-migrate for migrations.
We are using Sequelize.js in our Node project and I guess it kind of does the job done but there are gotchas. One example is that the MySQL Sequelize query engine does case sensitive string matching on the SQL string that you feed it (this.sql.indexOf('SELECT') == 0). This means it can fail if your SQL happens to be lowercase. SQL keywords are usually case insensitive (although upper case by convention) so the Sequelize implementation seems like a hack.
There is migration support in Sequelize as of version 1.3.0 but I haven't used it and I'm considering rolling my own instead.
I come from a background of having used the Ruby ActiveRecord ORM and in light of this and the gotcha mentioned above I'm hesitant to recommend Sequelize. Unfortunately, I don't know what better alternatives are out there.
UPDATE1: there are other ORMs suggested under "Which ORM should I use for Node.js and MySQL?".
UPDATE2: I've released my Sequelize.js migration code on Github
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With