Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Define User Registration Routes 3:52
- Using Nodemon While Developing an Express App 3:20
- Creating a Registration Form With Pug (Jade) 7:18
- Review: Routes, Nodemon and Pug 5 questions
- Setting Up Mongoose and a Mongo Database 4:34
- Defining a Mongo Schema with Mongoose 4:44
- Adding Data to the Database 9:46
- Review: Mongo, Mongoose and Schemas 5 questions
- Hashing and Salting 2:53
- Storing Passwords Securely 5:54
- Review: Passwords, Hashing and Salting 5 questions
Well done!
You have completed User Authentication With Express and Mongo!

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
In this video, learn how to create a schema for MongoDB using Mongoose. You'll learn how to create a document schema with keys and additional properties to control the type of data Mongoose will store in MongoDB.
Resources
Mongoose Schemas Mongoose Methods
User model code for user.js
:
var mongoose = require('mongoose');
var UserSchema = new mongoose.Schema({
email: {
type: String,
required: true,
trim: true,
unique: true,
},
name: {
type: String,
required: true,
trim: true,
},
favoriteBook: {
type: String,
required: true,
trim: true
},
password: {
type: String,
required: true
}
});
var User = mongoose.model('User', UserSchema);
module.exports = User;
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
PLUS
Saud Tauqeer
Courses Plus Student 8,099 Points2 Answers
-
Jesse Thompson
10,684 Points4 Answers
-
Aayush Mitra
24,904 Points0 Answers
-
PLUS
paulscanlon
Courses Plus Student 26,735 Points1 Answer
-
NiKole Maxwell
11,083 Points2 Answers
-
Imran Malik
108 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up