From the course: Databases for Node.js Developers

Unlock the full course today

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

Create sequelize models

Create sequelize models

From the course: Databases for Node.js Developers

Start my 1-month free trial

Create sequelize models

- [Instructor] We will now define the models for our sequelize in our shopper application. And spoiler alert, these models will then also be used to automatically create the tables and relationships in the database. So let's head to server, models and in models, I will now create a new directory sequelize. And in sequelize, I create a file index.js. So we could now go ahead and also create one dedicated file per database table like we did for mongoose, but with sequelize that's rather complicated as order and order item will always be used together, I decided to just leave them in one file. So we can just go ahead now and add const, and then we want to bring in the data types that sequelize provides, so in curly brackets I now add DataTypes equals require sequelize. So this will now basically fetch the property data types from sequelize. Then I start with module.export, so this is what we actually want to export. And we…

Contents