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
송용우
2020-08-14 00:56:00 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
93853b466073aff220e602a2deeafd0a8b7322a9
93853b46
1 parent
99203d12
Edit models/challenge.js Typo
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
45 deletions
jaksimsamil-server/src/models/challenge.js
jaksimsamil-server/src/models/challenge.js
View file @
93853b4
const
mongoose
=
require
(
"mongoose"
);
const
{
Schema
}
=
mongoose
;
const
{
Schema
}
=
mongoose
;
const
GroupSchema
=
new
Schema
({
members
:{
type
:[
String
]
},
const
GroupSchema
=
new
Schema
({
members
:
{
type
:
[
String
]
},
});
const
ChallengeSchema
=
new
Schema
({
challengeName
:
{
type
:
String
,
required
:
true
},
startDate
:
{
type
:
Object
,
required
:
true
},
endDate
:
{
type
:
Object
,
required
:
true
},
durationPerSession
:
{
type
:
String
,
required
:
true
},
// '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
goalPerSession
:
{
type
:
Number
,
required
:
true
},
// number of problems for one session
groups
:{
type
:
[
GroupSchema
],
required
:
true
},
// groups attending challenge, group of only one member supposed to be single
const
ChallengeSchema
=
new
Schema
({
challengeName
:
{
type
:
String
,
required
:
true
},
startDate
:
{
type
:
Object
,
required
:
true
},
endDate
:
{
type
:
Object
,
required
:
true
},
durationPerSession
:
{
type
:
String
,
required
:
true
},
// '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
goalPerSession
:
{
type
:
Number
,
required
:
true
},
// number of problems for one session
groups
:
{
type
:
[
GroupSchema
],
required
:
true
},
// groups attending challenge, group of only one member supposed to be single
});
ChallengeSchema
.
statics
.
findByChallengeName
=
function
(
challengeName
)
{
return
this
.
findOne
({
challengeName
:
challengeName
});
}
ChallengeSchema
.
statics
.
findByChallengeName
=
function
(
challengeName
)
{
return
this
.
findOne
({
challengeName
:
challengeName
});
}
;
ChallengeSchema
.
methods
.
addNewGroup
=
function
(
group
)
{
this
.
groups
.
push
(
group
);
return
this
.
save
();
}
ChallengeSchema
.
methods
.
addNewGroup
=
function
(
group
)
{
this
.
groups
.
push
(
group
);
return
this
.
save
();
}
;
ChallengeSchema
.
methods
.
removeGroup
=
function
(
group_id
)
{
const
idx
=
this
.
groups
.
findIndex
((
item
)
=>
item
.
_id
===
group_id
);
this
.
groups
.
splice
(
idx
,
1
);
return
this
.
save
();
}
ChallengeSchema
.
methods
.
removeGroup
=
function
(
group_id
)
{
const
idx
=
this
.
groups
.
findIndex
((
item
)
=>
item
.
_id
===
group_id
);
this
.
groups
.
splice
(
idx
,
1
);
return
this
.
save
();
}
;
ChallengeSchema
.
methods
.
getChallengeName
=
function
()
{
return
this
.
challengeName
;
}
ChallengeSchema
.
methods
.
getChallengeName
=
function
()
{
return
this
.
challengeName
;
}
;
ChallengeSchema
.
methods
.
getStartDate
=
function
()
{
return
this
.
startDate
;
}
ChallengeSchema
.
methods
.
getStartDate
=
function
()
{
return
this
.
startDate
;
}
;
ChallengeSchema
.
methods
.
getEndDate
=
function
()
{
return
this
.
endDate
;
}
ChallengeSchema
.
methods
.
getEndDate
=
function
()
{
return
this
.
endDate
;
}
;
ChallengeSchema
.
method
.
getDurationPerSession
=
function
()
{
return
this
.
durationPerSession
;
}
ChallengeSchema
.
method
s
.
getDurationPerSession
=
function
()
{
return
this
.
durationPerSession
;
}
;
ChallengeSchema
.
methods
.
getGoalPerSession
=
function
()
{
return
this
.
goalPerSession
;
}
ChallengeSchema
.
methods
.
getGoalPerSession
=
function
()
{
return
this
.
goalPerSession
;
}
;
ChallengeSchema
.
methods
.
getGroups
=
function
()
{
return
this
.
groups
;
}
ChallengeSchema
.
methods
.
getGroups
=
function
()
{
return
this
.
groups
;
}
;
ChallengeSchema
.
methods
.
serialize
=
function
()
{
return
this
.
toJSON
();
}
ChallengeSchema
.
methods
.
serialize
=
function
()
{
return
this
.
toJSON
();
}
;
const
Challenge
=
mongoose
.
model
(
'Challenge'
,
ChallengeSchema
);
module
.
exports
=
Challenge
;
\ No newline at end of file
const
Challenge
=
mongoose
.
model
(
"Challenge"
,
ChallengeSchema
);
module
.
exports
=
Challenge
;
...
...
Please
register
or
login
to post a comment