Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
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
JJuOn
2020-08-13 09:51:35 +0900
1
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
53e17546c54a9a734bc12458234c3ffbef83509f
53e17546
1 parent
e26edb16
Implement models/problem.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
jaksimsamil-server/src/models/problem.js
jaksimsamil-server/src/models/problem.js
0 → 100644
View file @
53e1754
const
mongoose
=
require
(
'mongoose'
);
const
{
Schema
}
=
mongoose
;
const
ProblemSchema
=
new
Schema
({
problemNum
:
{
type
:
Number
,
required
:
true
,
unique
:
true
},
problemTitle
:
{
type
:
String
,
required
:
true
},
solvedacLevel
:
{
type
:
Number
},
sumbitNum
:
{
type
:
Number
,
required
:
true
},
correctNum
:
{
type
:
Number
,
required
:
true
},
category
:
{
type
:[
String
]}
});
ProblemSchema
.
statics
.
findByProblemNum
=
function
(
problemNum
){
return
this
.
findOne
({
problemNum
:
problemNum
});
}
ProblemSchema
.
methods
.
addCategory
=
function
(
category
){
this
.
category
.
push
(
category
);
return
this
.
save
();
}
ProblemSchema
.
methods
.
removeCategory
=
function
(
category
){
const
idx
=
this
.
category
.
findIndex
(
item
=>
item
===
category
);
this
.
splice
(
idx
,
1
);
return
this
.
save
();
}
ProblemSchema
.
methods
.
getProblemNum
=
function
(){
return
this
.
problemNum
;
}
ProblemSchema
.
methods
.
getProblemTitle
=
function
(){
return
this
.
problemTitle
;
}
ProblemSchema
.
methods
.
getSolvedacLevel
=
function
(){
return
this
.
solvedacLevel
;
}
ProblemSchema
.
methods
.
getSumbitNum
=
function
(){
return
this
.
sumbitNum
;
}
ProblemSchema
.
methods
.
getCorrectNum
=
function
(){
return
this
.
correctNum
;
}
ProblemSchema
.
methods
.
getCategory
=
function
(){
return
this
.
category
;
}
ProblemSchema
.
methods
.
serialize
=
function
(){
return
this
.
toJSON
();
}
const
Problem
=
mongoose
.
model
(
'Problem'
,
ProblemSchema
);
module
.
exports
=
Problem
;
\ No newline at end of file
송용우
@2019102188
2020-09-26 12:41:25 UTC
Mentioned in commit
99203d12
Please
register
or
login
to post a comment