For building a MERN App
const mongoose = require('mongoose')
const UserSchema = new mongoose.Schema({
name:{
type: String,
required: true
},
email:{
type: String,
required: true,
unique: true
},
avatar: {
type: String
},
password: {
type: String,
required: true
},
date: {
type: Date,
default: Date.now
}
});
module.exports = User = mongoose.model('user',UserSchema);
Expecting to form a user model which can be used to store posts an other things later
CodePudding user response:
Your answer looks like correct to me, you just need to use it in the routes or in any other models as per you need using :
const User = require('../../models/User');