users.model.js 529 Bytes
Newer Older
Park Sungwoo's avatar
123    
Park Sungwoo committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import mongoose from "mongoose";

const validateEmail = (email => {
    const re = /^\w+([\,-]?\w+)*@\w+([\,-]?\w+)*(\.\w{2,3})+$/; 
    return re.test(email)
})

const schema = new mongoose.Schema({
    email:{
        type: String,
        rquired: true,
        unique: true,
        validate: [validateEmail, "이메일을 입력해주세요."],
    },
    name: {type:string}, 
    password: { type: string, required: true, select: false},
    role:{type:schema.types.objectId, ref: "Role"},
    }
);

export default schema;