Commit 2cb5ab29 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

reservation, timetable model

parent fdd2a316
...@@ -3,6 +3,8 @@ import UserModel from "../models/user.model.js"; ...@@ -3,6 +3,8 @@ import UserModel from "../models/user.model.js";
import RoleModel from "../models/role.model.js"; import RoleModel from "../models/role.model.js";
import MovieModel from "../models/movie.model.js"; import MovieModel from "../models/movie.model.js";
import CinemaModel from "../models/cinema.model.js"; import CinemaModel from "../models/cinema.model.js";
import TimeTableModel from '../models/role.model.js';
import ReservationModel from '../models/reservation.model.js';
import dbConfig from "../config/db.config.js"; import dbConfig from "../config/db.config.js";
const sequelize = new Sequelize( const sequelize = new Sequelize(
...@@ -25,6 +27,8 @@ const User = UserModel(sequelize) ...@@ -25,6 +27,8 @@ const User = UserModel(sequelize)
const Role = RoleModel(sequelize) const Role = RoleModel(sequelize)
const Movie = MovieModel(sequelize) const Movie = MovieModel(sequelize)
const Cinema = CinemaModel(sequelize) const Cinema = CinemaModel(sequelize)
const TimeTable = TimeTableModel(sequelize)
const Reservation = ReservationModel(sequelize)
User.belongsTo(Role); User.belongsTo(Role);
Role.hasOne(User); Role.hasOne(User);
...@@ -37,5 +41,7 @@ export { ...@@ -37,5 +41,7 @@ export {
User, User,
Role, Role,
Movie, Movie,
Cinema Cinema,
TimeTable,
Reservation
} }
\ No newline at end of file
...@@ -10,7 +10,7 @@ dotenv.config({ ...@@ -10,7 +10,7 @@ dotenv.config({
}); });
sequelize sequelize
.sync({ force: true }) .sync({ force: false })
.then(async () => { .then(async () => {
await Promise.all( await Promise.all(
Object.keys(ROLE_NAME).map((name) => { Object.keys(ROLE_NAME).map((name) => {
......
import Sequelize from "sequelize";
const { DataTypes } = Sequelize;
const ReservationModel = (sequelize) => {
const Reservation = sequelize.define(
"reservation",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
movieId: {
type: DataTypes.INTEGER,
},
theater: {
type: DataTypes.INTEGER,
},
row: {
type: DataTypes.STRING,
},
col: {
type: DataTypes.INTEGER,
},
timetable:{
type: DataTypes.INTEGER,
},
user:{
type: DataTypes.INTEGER,
},
payment:{
type: DataTypes.INTEGER,
}
},
{
timestamps: true,
freezeTableName: true,
tableName: "reservations"
}
);
return Reservation;
};
export default ReservationModel;
\ No newline at end of file
import Sequelize from "sequelize";
const { DataTypes } = Sequelize;
const TimeTableModel = (sequelize) => {
const TimeTable = sequelize.define(
"timetable",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
theater: {
type: DataTypes.INTEGER,
},
movieId: {
type: DataTypes.INTEGER,
},
title: {
type: DataTypes.STRING,
},
release_date: {
type: DataTypes.STRING
},
date: {
type: DataTypes.STRING,
},
time: {
type: DataTypes.TIME,
},
},
{
// timestamps: true,
freezeTableName: true,
tableName: "timetables"
}
);
return TimeTable;
};
export default TimeTableModel;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment