From the course: Databases for Node.js Developers

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Introduction to Sequelize

Introduction to Sequelize

From the course: Databases for Node.js Developers

Start my 1-month free trial

Introduction to 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's not exclusive for MySQL. It supports MySQL, but also SQLite, PostgreSQL, and Microsoft SQL Server. Additionally to being a database abstraction layer, it's also an object relational mapper, an ORM, very similar to Mongoose, which is an object document mapper. So as we did it with Mongoose we could not do something like that. I could define a car and a property, make on it, and I can tell Sequelize that this should be a string. And then I call sequelize.sync in a special line different from Mongoose because this will synchronize the database model here with the database. So basically, it really creates the static table for us in MySQL. Then I call Car.create and pass in the make, and it's Ford in my case, and this, again, returns a promise and in the then block I can…

Contents