Commit 20930c8b authored by Kim, Subin's avatar Kim, Subin
Browse files

ku&schedule model 작성 및 적용

parent 74c9439e
import { Sequelize } from "sequelize" import { Sequelize } from "sequelize"
import dbConfig from "../config/db.config.js" import dbConfig from "../config/db.config.js"
import UserModel from "../models/user.model.js"; import UserModel from "../models/user.model.js";
import KUModel from "../models/ku.model.js";
import ScheduleModel from "../models/schedule.model.js";
import TodoModel from "../models/todo.model.js"; import TodoModel from "../models/todo.model.js";
import SubjectModel from "../models/subject.model.js"; import SubjectModel from "../models/subject.model.js";
...@@ -21,14 +23,19 @@ const sequelize = new Sequelize( ...@@ -21,14 +23,19 @@ const sequelize = new Sequelize(
); );
const User = UserModel(sequelize) const User = UserModel(sequelize)
const KU = KUModel(sequelize)
const Schedule = ScheduleModel(sequelize)
const Todo = TodoModel(sequelize) const Todo = TodoModel(sequelize)
const Subject = SubjectModel(sequelize) const Subject = SubjectModel(sequelize)
Schedule.belongsTo(User)
Subject.belongsTo(User) Subject.belongsTo(User)
export { export {
sequelize, sequelize,
User, User,
KU,
Schedule,
Todo, Todo,
Subject Subject
} }
\ No newline at end of file
import Sequelize from "sequelize";
const { DataTypes } = Sequelize;
const KUModel = (sequelize) => {
const KU = sequelize.define(
"ku",
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
title: {
type: DataTypes.STRING,
allowNull: false
},
start: {
type: DataTypes.DATE,
allowNull: false
},
end: {
type: DataTypes.DATE
},
memo: {
type: DataTypes.TEXT
}
},
{
timestamps: true,
freezeTableName: true
}
)
return KU
}
export default KUModel
\ No newline at end of file
import Sequelize from "sequelize";
const { DataTypes } = Sequelize;
const ScheduleModel = (sequelize) => {
const Schedule = sequelize.define(
"schedule",
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
title: {
type: DataTypes.STRING,
allowNull: false
},
start: {
type: DataTypes.DATE,
allowNull: false
},
end: {
type: DataTypes.DATE
},
location: {
type:DataTypes.STRING
},
memo: {
type: DataTypes.TEXT
}
},
{
timestampts: true,
}
)
return Schedule
}
export default ScheduleModel
\ No newline at end of file
...@@ -64,5 +64,4 @@ const UserModel = (sequelize) => { ...@@ -64,5 +64,4 @@ const UserModel = (sequelize) => {
return User return User
}; };
export default UserModel; export default UserModel;
\ No newline at end of file
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