index.js 966 Bytes
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import { Sequelize } from "sequelize";
2
3
import UserModel from "../models/user.model.js";
import RoleModel from "../models/role.model.js";
Kim, Subin's avatar
Model    
Kim, Subin committed
4
import MovieModel from "../models/movie.model.js";
Kim, Subin's avatar
Kim, Subin committed
5
import CinemaModel from "../models/cinema.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
23
import dbConfig from "../config/db.config.js";

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,
        },
    }
);

24
25
const User = UserModel(sequelize)
const Role = RoleModel(sequelize)
Kim, Subin's avatar
Model    
Kim, Subin committed
26
const Movie = MovieModel(sequelize)
Kim, Subin's avatar
Kim, Subin committed
27
const Cinema = CinemaModel(sequelize)
Kim, Subin's avatar
Model    
Kim, Subin committed
28

29
30
31
User.belongsTo(Role);
Role.hasOne(User);

한규민's avatar
한규민 committed
32
33
34
User.belongsTo(Role);
Role.hasOne(User);

Kim, Subin's avatar
Kim, Subin committed
35
36
export {
    sequelize,
37
38
    User,
    Role,
Kim, Subin's avatar
Kim, Subin committed
39
40
    Movie,
    Cinema
Kim, Subin's avatar
Kim, Subin committed
41
}