Commit c54b5a00 authored by Kim, Subin's avatar Kim, Subin
Browse files

Role model 추가 및 User model 수정

parent af0b4d10
import { Sequelize } from "sequelize"; import { Sequelize } from "sequelize";
// import UserModel from "../models/user.model.js"; import UserModel from "../models/user.model.js";
import RoleModel from "../models/role.model.js";
import MovieModel from "../models/movie.model.js"; import MovieModel from "../models/movie.model.js";
import dbConfig from "../config/db.config.js"; import dbConfig from "../config/db.config.js";
...@@ -19,11 +20,16 @@ const sequelize = new Sequelize( ...@@ -19,11 +20,16 @@ const sequelize = new Sequelize(
} }
); );
// const User = UserModel(sequelize) const User = UserModel(sequelize)
const Role = RoleModel(sequelize)
const Movie = MovieModel(sequelize) const Movie = MovieModel(sequelize)
User.belongsTo(Role);
Role.hasOne(User);
export { export {
sequelize, sequelize,
// User, User,
Role,
Movie Movie
} }
\ No newline at end of file
...@@ -2,12 +2,12 @@ import Sequelize from "sequelize"; ...@@ -2,12 +2,12 @@ import Sequelize from "sequelize";
const { DataTypes } = Sequelize; const { DataTypes } = Sequelize;
// export const ROLE_NAME = { export const ROLE_NAME = {
// USER = "user", USER : "user",
// MEMBER = "member", MEMBER : "member",
// ADMIN = "admin", ADMIN : "admin",
// ROOT = "root", ROOT : "root",
// } }
const RoleModel = (sequelize) => { const RoleModel = (sequelize) => {
const Role = sequelize.define( const Role = sequelize.define(
......
...@@ -28,11 +28,6 @@ const UserModel = (sequelize) => { ...@@ -28,11 +28,6 @@ const UserModel = (sequelize) => {
phoneNumber: { phoneNumber: {
type: DataTypes.INTEGER type: DataTypes.INTEGER
}, },
// role: {
// type: DataTypes.ENUM({
// values: Object.values(ROLE_NAME),
// }),
// }
}, },
{ {
timestamps: true, timestamps: true,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment