index.js 1.81 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'
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);

46
Theater.belongsTo(TheaterType, { onDelete: 'CASCADE' });
Kim, Subin's avatar
theater    
Kim, Subin committed
47
48

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

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