31 lines
676 B
JavaScript
31 lines
676 B
JavaScript
const mongoose = require('mongoose')
|
|
const ObjectID = mongoose.Schema.Types.ObjectId
|
|
|
|
const userSchema = new mongoose.Schema(
|
|
{
|
|
name: String,
|
|
password: {
|
|
type: String,
|
|
required: true,
|
|
trim: true,
|
|
},
|
|
isActive: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
role: {
|
|
type: ObjectID,
|
|
ref: 'Role'
|
|
},
|
|
isAdmin: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
},
|
|
{ toJSON: { virtuals: true }, toObject: { virtuals: true }, timestamps: true }
|
|
)
|
|
|
|
const User = mongoose.model('User', userSchema)
|
|
|
|
module.exports = User
|