User.js 1.11 KB
Newer Older
우지원's avatar
우지원 committed
1
2
3
4
//주고받는 형식을 정의함.

import mongoose from 'mongoose'

5
const { String } = mongoose.Schema.Types
JeongYeonwoo's avatar
JeongYeonwoo committed
6
const { Array } = mongoose.Schema.Types
우지원's avatar
우지원 committed
7
8
9
10
11
//원래 java의 string이 아니라 mongoose의 string을 쓰기 위해 불러옴.
//object의 id를 쓸때에도 추가시켜줘야됨.

//형식을 정의함.
const UserSchema = new mongoose.Schema({
우지원's avatar
a    
우지원 committed
12
    username: {
우지원's avatar
우지원 committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
        type: String,
        required: true,
    },
    nickname: {
        type: String,
        required: true,
    },
    email: {
        type: String,
        required: true,
        unique: true,
        //unique: 같은 email을 두번넣으면 error발생함
    },
    password: {
        type: String,
        required: true,
        select: false,
        //정보를 찾을때 찾지 않게함
        //플러스 옵션을 주면 찾을 수 있음(mongoose에서 용법찾아봐야됨)
    },
JeongYeonwoo's avatar
JeongYeonwoo committed
33
    profileimg: {
JeongYeonwoo's avatar
JeongYeonwoo committed
34
        type: String,
JeongYeonwoo's avatar
JeongYeonwoo committed
35
        default: '3cd14b9bcb2007f324fcb82e0b566cce',
JeongYeonwoo's avatar
JeongYeonwoo committed
36
    },
JeongYeonwoo's avatar
JeongYeonwoo committed
37
38
39
    entrylog: {
        type: Array,
    }
JeongYeonwoo's avatar
JeongYeonwoo committed
40
}, {
Choi Ga Young's avatar
Choi Ga Young committed
41
   
우지원's avatar
우지원 committed
42
    timestamps: true
Choi Ga Young's avatar
Choi Ga Young committed
43
   
우지원's avatar
우지원 committed
44
45
46
})

export default mongoose.models.User || mongoose.model('User', UserSchema)
Choi Ga Young's avatar
Choi Ga Young committed
47