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 a user model for Sequelize - Node.js Tutorial
From the course: Databases for Node.js Developers
Creating a user model for Sequelize
- [Instructor] Now that we have designed our database, in this video, we will define the user model using Sequelize. This will feel familiar from what we did with MongoDB and Mongoose. So let's create our first model, and for that, I go into Source, Models, and as we have it for Mongoose, we also have a folder for Sequelize. And in there, I now create a new file, and I call it User.js, uppercase U, and this will hold a user model, and there, I start with importing the data types of Sequelize. So I write import (keys clicking) DataTypes from sequelize. (keys clicking) Next, I'm starting with exporting a default function (keys clicking) that takes sequelize as an argument. (keys clicking) And there in the function body, we will define our model, and that's really again very similar to MongoDB because in there, I now write const User = sequelize (keys clicking) and we don't have to bring in sequelize as you see, because it's coming in in line three, so it's a function parameter. And on…
Contents
-
-
-
-
-
-
(Locked)
Using MySQL for our users and orders1m 8s
-
(Locked)
Setting up MySQL with Docker2m 49s
-
(Locked)
Exploring MySQL with MySQL Workbench1m 57s
-
(Locked)
Introducing Sequelize1m 51s
-
(Locked)
Setting up the database connection7m 43s
-
(Locked)
Designing the database structure2m 1s
-
(Locked)
Creating a user model for Sequelize7m 47s
-
(Locked)
Creating the order models for Sequelize11m 56s
-
(Locked)
Loading and syncing the models13m 5s
-
(Locked)
Creating, updating and deleting users with Sequelize12m 52s
-
(Locked)
Securing credentials with password hashing7m 2s
-
(Locked)
Implementing the user login9m 15s
-
(Locked)
-
-
-