1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| const mOngoose= require('mongoose');
const Schema = mongoose.Schema;
// create Comment Schema & model
const UserSchema = new Schema({
uid: {
type : Number,
index: {
unique: true
},
},
username: {
type: String,
required: [true, 'username field is required']
},
password: {
type: String,
required: [true, 'username field is required']
},
headImageUrl: {
type: String,
},
created: {
type: Date,
default: Date.now
},
admin: {
type: Boolean,
default: false
}
});
const User = mongoose.model('users', UserSchema);
module.exports = User; |