From the course: Databases for Node.js Developers

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Introducing Sequelize

Introducing Sequelize

- [Instructor] To use MySQL in our sample project, we will now use Sequelize. Sequelize is a popular database abstraction layer for Node.JS and it supports a few databases like MySQL, SQLite, Postgres, and Microsoft SQL Server. Additionally to being a database abstraction layer, it's also a object relational mapper, which is very similar to Mongoose, which is a object document mapper. So as we did with Mongoose, we could now do something like this. I could define something like a schema or model using SQL as define, and I call it car, and I say it has a make and this make is of the data type string. And then we can very simply just sync this model to MySQL and it'll be automatically created. And then I can create a database record for this car and it'll be stored to MySQL. And now I can, for instance, log it out or set more properties on it, et cetera. You see, that's very similar to Mongoose. Now let's look at something important, it's transactions. So how can transactions be created…

Contents