Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오인제
/
Tunnel
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
고병후
2021-12-08 20:59:39 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e4f96efc14c8e1c8bd3ebb038798787727749cd8
e4f96efc
1 parent
86303e04
Create post,comment DB
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
tunnel_BE/server/models/comment.js
tunnel_BE/server/models/index.js
tunnel_BE/server/models/post.js
tunnel_BE/server/models/comment.js
0 → 100644
View file @
e4f96ef
const
Sequelize
=
require
(
'sequelize'
);
module
.
exports
=
class
Comment
extends
Sequelize
.
Model
{
static
init
(
sequelize
)
{
return
super
.
init
({
comment
:{
type
:
Sequelize
.
TEXT
,
allowNull
:
false
,
},
created_at
:{
type
:
Sequelize
.
DATE
,
allowNull
:
false
,
defaultValue
:
Sequelize
.
NOW
,
},
},{
sequelize
,
timestamps
:
false
,
underscored
:
false
,
modelName
:
'Comment'
,
tableName
:
'comments'
,
paranoid
:
false
,
charset
:
'utf8'
,
collate
:
'utf8_general_ci'
,
});
}
static
associate
(
db
)
{}
};
\ No newline at end of file
tunnel_BE/server/models/index.js
View file @
e4f96ef
...
...
@@ -3,6 +3,8 @@ const Sequelize = require('sequelize');
//table(모델)과 연결
const
User
=
require
(
"./user.js"
);
const
Comment
=
require
(
"./comment.js"
);
const
Post
=
require
(
"./post.js"
);
const
env
=
process
.
env
.
NODE_ENV
||
'development'
;
//개발버전
const
config
=
require
(
'../config/config.json'
)[
env
];
...
...
@@ -14,8 +16,16 @@ const sequelize = new Sequelize(config.database, config.username, config.passwor
db
.
sequelize
=
sequelize
;
db
.
User
=
User
;
db
.
Comment
=
Comment
;
db
.
Post
=
Post
;
User
.
init
(
sequelize
);
Comment
.
init
(
sequelize
);
Post
.
init
(
sequelize
);
User
.
associate
(
db
);
Comment
.
associate
(
db
);
Post
.
associate
(
db
);
module
.
exports
=
db
;
...
...
tunnel_BE/server/models/post.js
0 → 100644
View file @
e4f96ef
const
Sequelize
=
require
(
'sequelize'
);
module
.
exports
=
class
Post
extends
Sequelize
.
Model
{
static
init
(
sequelize
)
{
return
super
.
init
({
title
:{
type
:
Sequelize
.
TEXT
,
allowNull
:
false
,
},
post
:{
type
:
Sequelize
.
TEXT
,
allowNull
:
false
,
},
status
:{
type
:
Sequelize
.
BOOLEAN
,
allowNull
:
false
,
},
created_at
:{
type
:
Sequelize
.
DATE
,
allowNull
:
false
,
defaultValue
:
Sequelize
.
NOW
,
},
},{
sequelize
,
timestamps
:
false
,
underscored
:
false
,
modelName
:
'Post'
,
tableName
:
'posts'
,
paranoid
:
false
,
charset
:
'utf8'
,
collate
:
'utf8_general_ci'
,
});
}
static
associate
(
db
)
{}
};
\ No newline at end of file
Please
register
or
login
to post a comment