index.js 1.67 KB
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
import TheaterModel from "../models/theater.model.js";
Kim, Subin's avatar
theater    
Kim, Subin committed
7
import TheaterTypeModel from "../models/theatertype.model.js";
Kim, Subin's avatar
Kim, Subin committed
8
import TicketFeeModel from "../models/ticketfee.model.js";
Jiwon Yoon's avatar
Jiwon Yoon committed
9
10
import TimeTableModel from '../models/role.model.js';
import ReservationModel from '../models/reservation.model.js';
Jiwon Yoon's avatar
Jiwon Yoon committed
11
import GuestModel from '../models/guest.model.js'
Kim, Subin's avatar
Kim, Subin committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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,
        },
    }
);

30
31
const User = UserModel(sequelize)
const Role = RoleModel(sequelize)
Kim, Subin's avatar
Model    
Kim, Subin committed
32
const Movie = MovieModel(sequelize)
Kim, Subin's avatar
Kim, Subin committed
33
const Cinema = CinemaModel(sequelize)
Kim, Subin's avatar
Kim, Subin committed
34
const Theater = TheaterModel(sequelize)
Kim, Subin's avatar
theater    
Kim, Subin committed
35
const TheaterType = TheaterTypeModel(sequelize)
Kim, Subin's avatar
Kim, Subin committed
36
const TicketFee = TicketFeeModel(sequelize)
Jiwon Yoon's avatar
Jiwon Yoon committed
37
38
const TimeTable = TimeTableModel(sequelize)
const Reservation = ReservationModel(sequelize)
Jiwon Yoon's avatar
Jiwon Yoon committed
39
const Guest = GuestModel(sequelize)
Kim, Subin's avatar
Model    
Kim, Subin committed
40

41
42
43
User.belongsTo(Role);
Role.hasOne(User);

Kim, Subin's avatar
theater    
Kim, Subin committed
44
45
46
Theater.belongsTo(TheaterType);

TicketFee.belongsTo(TheaterType, { onDelete: 'CASCADE' });
한규민's avatar
한규민 committed
47

Kim, Subin's avatar
Kim, Subin committed
48
49
export {
    sequelize,
50
51
    User,
    Role,
Kim, Subin's avatar
Kim, Subin committed
52
    Movie,
Kim, Subin's avatar
Kim, Subin committed
53
    Cinema,
Jiwon Yoon's avatar
Jiwon Yoon committed
54
    Theater,
Kim, Subin's avatar
theater    
Kim, Subin committed
55
    TheaterType,
Kim, Subin's avatar
Kim, Subin committed
56
    TicketFee,
Jiwon Yoon's avatar
Jiwon Yoon committed
57
    TimeTable,
Jiwon Yoon's avatar
Jiwon Yoon committed
58
59
    Reservation,
    Guest
Kim, Subin's avatar
Kim, Subin committed
60
}