JJuOn

Force collection name

......@@ -9,6 +9,8 @@ const ChallengeSchema=new Schema({
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
isOpen: { type: Boolean }
},{
collection: 'challenge'
});
ChallengeSchema.statics.findByChallengeName=function(challengeName){
......
......@@ -4,6 +4,8 @@ const { Schema } = mongoose;
const GroupSchema = new Schema({
members: [{ type: Schema.Types.ObjectId, ref: 'User' }]
},{
collection: 'group'
});
const Group = mongoose.model('Group',GroupSchema);
......
......@@ -5,6 +5,8 @@ const { Schema } = mongoose;
const ParticipationSchema = new Schema({
sessionId: { type: Schema.Types.ObjectId, ref: 'Session' },
groupId: { type: Schema.Types.ObjectId, ref: 'Group' }
},{
collection: 'particiaption'
});
const Participation = mongoose.model('Participation', ParticipationSchema);
......
......@@ -10,6 +10,8 @@ const ProblemSchema=new Schema({
correctNum: {type: Number, required: true},
count: { type: Number },
category: {type:[String]}
},{
collection: 'problem'
});
ProblemSchema.statics.findByProblemNum=function(problemNum){
......@@ -59,5 +61,5 @@ ProblemSchema.methods.serialize=function(){
return this.toJSON();
}
const Problem=mongoose.model('Problem',ProblemSchema);
module.exports=Problem;
\ No newline at end of file
const Problem = mongoose.model('Problem',ProblemSchema);
module.exports = Problem;
\ No newline at end of file
......
......@@ -5,7 +5,10 @@ const { Schema } = mongoose;
const SessionSchema = new Schema({
challengeId: { type: Schema.Types.ObjectId, ref: 'Challenge' },
sessionStartDate: { type: Object },
sessionEndDate: { type: Object }
sessionEndDate: { type: Object },
isOpen: { type: Boolean }
},{
collection: 'session'
});
const Session = mongoose.model('Session', SessionSchema);
......
......@@ -13,6 +13,8 @@ const UserSchema = new Schema({
friendList: [{ type: Schema.Types.ObjectId, ref: 'User' }],
slackWebHookURL: String,
goalNum: Number,
},{
collection: 'user'
});
UserSchema.statics.findByUsername = function (username) {
......