Let's start with adding the functionality to sign up users to our app.
Setting up user registration
Creating a User model
We don't have a collection yet to manage the users. We will have three parameters in our User model: name, email, and password. Let's go ahead and create our User model called User.js in the models directory:
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const UserSchema = new Schema({
name: String,
email: String,
password: String,
});
const User = mongoose.model('User', UserSchema);
module.exports = User;
As you can see, the following are the three attributes for the user: name, email, and password.