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.

Creating the order models for Sequelize

Creating the order models for Sequelize - Node.js Tutorial

From the course: Databases for Node.js Developers

Creating the order models for Sequelize

- [Instructor] In the previous video, we created the user model. Now we want to create the models for our order management. We will create the order model which represents a single order which is associated with the user, and we will also create the order item model that stores the individual items of each order. Before we start this, I want to do a little optimization on the user object because I had an idea here, let's open User.js first. And you see that I'm bringing in the DataTypes from sequelize, but at the same time I'm also already bringing in sequelize in line three. So actually what we can do is we can remove this line and I will now add an argument, DataTypes. So later when we call and initialize these models, we have to add this as an argument. What we could also do is we could also extract or get DataTypes directly from the sequelize object, but let's leave it like that for clarity. Now we will build the order model. So I closed the use the User.js file and in the…

Contents