[React] BE 로그인/회원가입 구현(1) 유저 스키마 생성

jieun·2021년 4월 15일
0

디렉토리, 파일 생성

server/models 디렉토리 생성
server/models/User.js 파일 생성

User.js

const mongoose = require('mongoose');

const userSchema = mongoose.Schema({
    name: {
        type: String,
        maxlength: 100
    },
    email: {
        type: String,
        trim: true,
        unique: 1
    },
    password: {
        type: String,
        minlength: 10
    },
    role: {
        type: Number,
        default: 0
    },
    image: String,
    token: {
        type: String
    },
    tokenExp: {
        type: Number
    }
})

const User = mongoose.model('User', userSchema)
module.exports = {User}
profile
개발새발 블로그

0개의 댓글