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
JuWon Seo
2020-08-31 16:41:01 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Committed by
GitHub
2020-08-31 16:41:01 +0900
Commit
cf49fed7b95a0401a44517be1a907ba578a474c6
cf49fed7
2 parents
7a39581f
d7bbb4ba
Merge pull request #21 from FacerAin/feature/database
Feature/database
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
6 deletions
jaksimsamil-server/src/models/challenge.js
jaksimsamil-server/src/models/group.js
jaksimsamil-server/src/models/participation.js
jaksimsamil-server/src/models/problem.js
jaksimsamil-server/src/models/session.js
jaksimsamil-server/src/models/user.js
jaksimsamil-server/src/models/challenge.js
View file @
cf49fed
...
...
@@ -42,7 +42,9 @@ ChallengeSchema.methods.getStatus=function(){
}
ChallengeSchema
.
methods
.
serialize
=
function
(){
return
this
.
toJSON
();
let
challengeJSON
=
this
.
toJSON
();
delete
challengeJSON
.
_id
;
return
challengeJSON
;
}
const
Challenge
=
mongoose
.
model
(
'Challenge'
,
ChallengeSchema
);
...
...
jaksimsamil-server/src/models/group.js
View file @
cf49fed
...
...
@@ -3,12 +3,17 @@ const mongoose = require("mongoose");
const
{
Schema
}
=
mongoose
;
const
GroupSchema
=
new
Schema
({
groupName
:
{
type
:
String
},
members
:
[{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'User'
}]
},{
collection
:
'group'
});
GroupSchema
.
methods
.
addGroupMemeber
=
function
(
user
){
GroupSchema
.
statics
.
findByGroupName
=
function
(
groupName
){
return
this
.
find
({
groupName
:
groupName
});
}
GroupSchema
.
methods
.
addGroupMember
=
function
(
user
){
this
.
members
.
push
(
user
.
_id
);
return
this
.
save
();
}
...
...
@@ -18,7 +23,9 @@ GroupSchema.methods.getMembers=function(){
}
GroupSchema
.
methods
.
serialize
=
function
(){
return
this
.
toJSON
();
let
groupJSON
=
this
.
toJSON
();
delete
groupJSON
.
_id
;
return
groupJSON
;
}
const
Group
=
mongoose
.
model
(
'Group'
,
GroupSchema
);
...
...
jaksimsamil-server/src/models/participation.js
View file @
cf49fed
...
...
@@ -29,5 +29,11 @@ ParticipationSchema.methods.addProblem=function(problem){
this
.
problems
.
push
({
problemNum
:
problem
.
problemNum
,
isSolved
:
problem
.
isSolved
});
}
ParticipationSchema
.
methods
.
serialize
=
function
(){
let
participationJSON
=
this
.
toJSON
();
delete
participationJSON
.
_id
;
return
participationJSON
;
}
const
Participation
=
mongoose
.
model
(
'Participation'
,
ParticipationSchema
);
module
.
exports
=
Participation
;
\ No newline at end of file
...
...
jaksimsamil-server/src/models/problem.js
View file @
cf49fed
...
...
@@ -58,7 +58,9 @@ ProblemSchema.methods.getCategory=function(){
}
ProblemSchema
.
methods
.
serialize
=
function
(){
return
this
.
toJSON
();
let
problemJSON
=
this
.
toJSON
();
delete
problemJSON
.
_id
;
return
problemJSON
;
}
const
Problem
=
mongoose
.
model
(
'Problem'
,
ProblemSchema
);
...
...
jaksimsamil-server/src/models/session.js
View file @
cf49fed
...
...
@@ -28,7 +28,9 @@ SessionSchema.methods.getStatus=function(){
}
SessionSchema
.
methods
.
serialize
=
function
(){
return
this
.
toJSON
();
let
sessionJSON
=
this
.
toJSON
();
delete
sessionJSON
.
_id
;
return
sessionJSON
;
}
const
Session
=
mongoose
.
model
(
'Session'
,
SessionSchema
);
...
...
jaksimsamil-server/src/models/user.js
View file @
cf49fed
...
...
@@ -38,13 +38,14 @@ UserSchema.methods.checkPassword = async function (password) {
UserSchema
.
methods
.
serialize
=
function
()
{
const
data
=
this
.
toJSON
();
delete
data
.
hashedPassword
;
delete
data
.
_id
;
return
data
;
};
UserSchema
.
methods
.
generateToken
=
function
()
{
const
token
=
jwt
.
sign
(
{
_id
:
this
.
id
,
_id
:
this
.
_
id
,
username
:
this
.
username
,
},
process
.
env
.
JWT_SECRET
,
...
...
Please
register
or
login
to post a comment