Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강연욱
/
myYoutube
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Flare-k
2020-05-26 20:54:57 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0d836f36049db73a810e90f99ef1e5e86b8db8c3
0d836f36
1 parent
9dc5696a
[Add] Schema and Model of VideoDB
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
init.js
models/Comment.js
models/Video.js
init.js
View file @
0d836f3
...
...
@@ -2,6 +2,7 @@ import app from "./app"; // app.js에서 export default app했기 때문에 불
import
"./db"
;
import
dotenv
from
"dotenv"
;
dotenv
.
config
();
import
"./models/Video"
;
const
PORT
=
process
.
env
.
PORT
||
80
;
...
...
models/Comment.js
0 → 100644
View file @
0d836f3
File mode changed
models/Video.js
0 → 100644
View file @
0d836f3
//DB 모델을 작성한다.
//Video 자체를 DB에 저장하진 않을 것이다. 즉, byte를 저장하는 것이 아니라 video의 link를 저장한다.
import
mongoose
from
"mongoose"
;
const
VideoSchema
=
new
mongoose
.
Schema
({
fileUrl
:
{
type
:
String
,
required
:
"File URL is required"
//url이 없으면 오류메시지 출력
},
title
:
{
type
:
String
,
required
:
"Title is required"
},
description
:
String
,
views
:
{
type
:
Number
,
default
:
0
//비디오를 처음 생성하면 views를 0으로..
},
createdAt
:
{
type
:
Date
,
default
:
Date
.
now
//현재 날짜를 반환하는 function
}
});
// 이제 이 스키마를 이용하여 model을 만들어준다.
//모델의 이름은 "Video"
const
model
=
mongoose
.
model
(
"Video"
,
VideoSchema
);
export
default
model
;
//모델이 만들어짐을 알리기 위해 init.js에 import해준다.
\ No newline at end of file
Please
register
or
login
to post a comment