User.js 895 Bytes
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
2
3
4
5
6
7
import mongoose from "mongoose";

const { String } = mongoose.Schema.Types

const UserSchema = new mongoose.Schema({
    name: {
        type: String,
이재연's avatar
이재연 committed
8
        required: true, // 꼭 필요한 값
Kim, Subin's avatar
Kim, Subin committed
9
    },
이재연's avatar
이재연 committed
10
    id: {
Kim, Subin's avatar
Kim, Subin committed
11
12
13
14
15
16
17
18
        type: String,
        required: true,
        unique: true,
    },
    password: {
        type: String,
        required: true,
    },
박상호's avatar
qwe    
박상호 committed
19
20
21
22
    number1: {
        type: String,
        required: true,
        unique: true
이재연's avatar
이재연 committed
23
    },
박상호's avatar
qwe    
박상호 committed
24
25
26
27
    number2: {
        type: String,
        required: true,
        unique: true
이재연's avatar
이재연 committed
28
    },
박상호's avatar
qwe    
박상호 committed
29
30
31
32
    tel: {
        type: String,
        required: true,
        unique: true
이재연's avatar
이재연 committed
33
    },
Kim, Subin's avatar
Kim, Subin committed
34
35
36
37
38
    role: {
        type: String,
        required: true,
        default: 'user',
        enum: ['user', 'admin', 'root']
박상호's avatar
qwe    
박상호 committed
39
40
41
42
43
    },
    avatarUrl: {
        type: String

    }, 
Kim, Subin's avatar
Kim, Subin committed
44
45
46
47
    timestamps: true
})

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