User.js 724 Bytes
Newer Older
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
1
import mongoose, { isValidObjectId } from "mongoose";
Lee SeoYeon's avatar
0111    
Lee SeoYeon committed
2
3

const { String } = mongoose.Schema.Types
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
4
const { Array } = mongoose.Schema.Types
Lee SeoYeon's avatar
0111    
Lee SeoYeon committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

const UserSchema = new mongoose.Schema({
    name: {
        type: String,
        required: true,
    },
    email: {
        type: String,
        required: true,
        unique: true,
    },
    password: {
        type: String,
        required: true,
        select: false,
    },
    role: {
        type: String,
        required: true,
        default: 'user',
        enum: ['user', 'admin', 'root']
    },
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
27
28
29
30
    bookmark: {
        type: Array,
        required: true,
    }
Lee SeoYeon's avatar
0111    
Lee SeoYeon committed
31
32
33
34
35
}, {
    timestamps: true
})

export default mongoose.models.User || mongoose.model('User', UserSchema)