index.js 812 Bytes
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 TodoModel from "../models/todo.model.js";
import SubjectModel from "../models/subject.model.js";
Kim, Subin's avatar
Kim, Subin committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

const sequelize = new Sequelize(
    String(dbConfig.database),
    String(dbConfig.username),
    dbConfig.password,
    {
        host: dbConfig.host,
        dialect: dbConfig.dialect,
        pool: {
            max: dbConfig.pool?.max,
            min: dbConfig.pool?.min,
            acquire: dbConfig.pool?.acquire,
            idle: dbConfig.pool?.idle,
        },
    }
);

23
const User = UserModel(sequelize)
24
25
26
27
const Todo = TodoModel(sequelize)
const Subject = SubjectModel(sequelize)

Subject.belongsTo(User)
28

Kim, Subin's avatar
Kim, Subin committed
29
30
export {
    sequelize,
31
    User,
32
33
    Todo,
    Subject
Kim, Subin's avatar
Kim, Subin committed
34
}