profile.js 880 Bytes
const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const ProfileSchema = new Schema({
    userId : { type : String, required : true, ref : 'User', lowercase : true, },
    userNm : { type : String, required : true, },
    birth : { type : String, required : true, },
    contact : { type : String, required : true, },
    useYn : { type : String, default : 'Y', },
    deviceToken : { type : String, default : null, },
});

ProfileSchema.statics.findByUserId = function(userId) {
    return this.findOne({ userId });
};

ProfileSchema.statics.setUseYn = function(useYn) {
    this.useYn = useYn;
};

ProfileSchema.methods.updateUserContact = function(contact) {
    this.contact = contact;
};

ProfileSchema.methods.updateDeviceToken = function(deviceToken) {
    this.deviceToken = deviceToken;
};


module.exports = mongoose.model('Profile', ProfileSchema);