index.js 1.93 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";
한규민's avatar
한규민 committed
9
import TimeTableModel from '../models/timetable.model.js';
Jiwon Yoon's avatar
Jiwon Yoon committed
10
import ReservationModel from '../models/reservation.model.js';
Jiwon Yoon's avatar
Jiwon Yoon committed
11
import GuestModel from '../models/guest.model.js'
12
import ConfirmNumModel from '../models/confirmnum.model.js'
Kim, Subin's avatar
Kim, Subin committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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,
        },
    }
);

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

43
44
45
User.belongsTo(Role);
Role.hasOne(User);

한규민's avatar
한규민 committed
46
47
48
Guest.belongsTo(Role);
Role.hasOne(Guest);

49
Theater.belongsTo(TheaterType, { onDelete: 'CASCADE' });
Kim, Subin's avatar
theater    
Kim, Subin committed
50
51

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

한규민's avatar
한규민 committed
53
54
55
Reservation.belongsTo(Theater);
Reservation.belongsTo(TimeTable);

Kim, Subin's avatar
Kim, Subin committed
56
57
export {
    sequelize,
58
59
    User,
    Role,
Kim, Subin's avatar
Kim, Subin committed
60
    Movie,
Kim, Subin's avatar
Kim, Subin committed
61
    Cinema,
Jiwon Yoon's avatar
Jiwon Yoon committed
62
    Theater,
Kim, Subin's avatar
theater    
Kim, Subin committed
63
    TheaterType,
Kim, Subin's avatar
Kim, Subin committed
64
    TicketFee,
Jiwon Yoon's avatar
Jiwon Yoon committed
65
    TimeTable,
Jiwon Yoon's avatar
Jiwon Yoon committed
66
    Reservation,
Jiwon Yoon's avatar
Jiwon Yoon committed
67
    Guest,
68
    ConfirmNum
Kim, Subin's avatar
Kim, Subin committed
69
}