Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
butter-studio
Commits
2cb5ab29
Commit
2cb5ab29
authored
Jul 24, 2021
by
Jiwon Yoon
Browse files
reservation, timetable model
parent
fdd2a316
Changes
4
Show whitespace changes
Inline
Side-by-side
server/db/index.js
View file @
2cb5ab29
...
@@ -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
server/index.js
View file @
2cb5ab29
...
@@ -10,7 +10,7 @@ dotenv.config({
...
@@ -10,7 +10,7 @@ dotenv.config({
});
});
sequelize
sequelize
.
sync
({
force
:
tru
e
})
.
sync
({
force
:
fals
e
})
.
then
(
async
()
=>
{
.
then
(
async
()
=>
{
await
Promise
.
all
(
await
Promise
.
all
(
Object
.
keys
(
ROLE_NAME
).
map
((
name
)
=>
{
Object
.
keys
(
ROLE_NAME
).
map
((
name
)
=>
{
...
...
server/models/reservation.model.js
0 → 100644
View file @
2cb5ab29
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
server/models/timetable.model.js
0 → 100644
View file @
2cb5ab29
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment