index.js 1.18 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
2
import { Sequelize } from "sequelize"
import dbConfig from "../config/db.config.js"
3
import UserModel from "../models/user.model.js";
4
5
import KUModel from "../models/ku.model.js";
import ScheduleModel from "../models/schedule.model.js";
6
7
import TodoModel from "../models/todo.model.js";
import SubjectModel from "../models/subject.model.js";
Choi Ga Young's avatar
Choi Ga Young committed
8
import PlanModel from "../models/plan.model.js";
Kim, Subin's avatar
Kim, Subin committed
9
10
11
12
13
14
15
16

const sequelize = new Sequelize(
    String(dbConfig.database),
    String(dbConfig.username),
    dbConfig.password,
    {
        host: dbConfig.host,
        dialect: dbConfig.dialect,
Kim, Subin's avatar
Kim, Subin committed
17
        timezone: dbConfig.timezone,
Kim, Subin's avatar
Kim, Subin committed
18
19
20
21
22
23
24
25
26
        pool: {
            max: dbConfig.pool?.max,
            min: dbConfig.pool?.min,
            acquire: dbConfig.pool?.acquire,
            idle: dbConfig.pool?.idle,
        },
    }
);

27
const User = UserModel(sequelize)
28
29
const KU = KUModel(sequelize)
const Schedule = ScheduleModel(sequelize)
30
31
const Todo = TodoModel(sequelize)
const Subject = SubjectModel(sequelize)
Choi Ga Young's avatar
Choi Ga Young committed
32
const Plan = PlanModel(sequelize)
33

34
Schedule.belongsTo(User)
35
Subject.belongsTo(User)
Kim, Subin's avatar
Kim, Subin committed
36
Todo.belongsTo(User)
Choi Ga Young's avatar
Choi Ga Young committed
37
Plan.belongsTo(Subject)
38

Kim, Subin's avatar
Kim, Subin committed
39
40
export {
    sequelize,
41
    User,
42
43
    KU,
    Schedule,
44
    Todo,
Choi Ga Young's avatar
Choi Ga Young committed
45
46
    Subject,
    Plan
Kim, Subin's avatar
Kim, Subin committed
47
}