DB/ETC

[mongodb] model & Schema 생성

꿈꾸는토끼 2021. 2. 24. 17:01
const mongoose = require('mongoose')

const userSchema = mongoose.Schema({

    name :{
        type : String,
        maxlength : 50
    },
    email : {
        type : String,
        trim : true,
        unique : 1
    },
    passworld : {
        type : String,
        minlegth : 5
    },
    lastname :{
        type : String,
        maxlength : 50
    },
    role : {
        type : Number,
        default : 0
    },
    image : String,
    token : {
        type : String
    },
    tokenExp : {
        type : Number
    }

})

const User = mongoose.model('User', userSchema)
module.exports = {User}