课程: Databases for Node.js Developers (2021)

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Create sequelize models

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…

内容