课程: Databases for Node.js Developers
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
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…
内容
-
-
-
-
-
-
(已锁定)
Using MySQL for our users and orders1 分钟 8 秒
-
(已锁定)
Setting up MySQL with Docker2 分钟 49 秒
-
(已锁定)
Exploring MySQL with MySQL Workbench1 分钟 57 秒
-
(已锁定)
Introducing Sequelize1 分钟 51 秒
-
(已锁定)
Setting up the database connection7 分钟 43 秒
-
(已锁定)
Designing the database structure2 分钟 1 秒
-
(已锁定)
Creating a user model for Sequelize7 分钟 47 秒
-
(已锁定)
Creating the order models for Sequelize11 分钟 56 秒
-
(已锁定)
Loading and syncing the models13 分钟 5 秒
-
(已锁定)
Creating, updating and deleting users with Sequelize12 分钟 52 秒
-
(已锁定)
Securing credentials with password hashing7 分钟 2 秒
-
(已锁定)
Implementing the user login9 分钟 15 秒
-
(已锁定)
-
-
-