JJuOn

Force collection name

...@@ -9,6 +9,8 @@ const ChallengeSchema=new Schema({ ...@@ -9,6 +9,8 @@ const ChallengeSchema=new Schema({
9 durationPerSession: {type: String, required: true}, // '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session. 9 durationPerSession: {type: String, required: true}, // '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
10 goalPerSession: {type: Number, required:true}, // number of problems for one session 10 goalPerSession: {type: Number, required:true}, // number of problems for one session
11 isOpen: { type: Boolean } 11 isOpen: { type: Boolean }
12 +},{
13 + collection: 'challenge'
12 }); 14 });
13 15
14 ChallengeSchema.statics.findByChallengeName=function(challengeName){ 16 ChallengeSchema.statics.findByChallengeName=function(challengeName){
......
...@@ -4,6 +4,8 @@ const { Schema } = mongoose; ...@@ -4,6 +4,8 @@ const { Schema } = mongoose;
4 4
5 const GroupSchema = new Schema({ 5 const GroupSchema = new Schema({
6 members: [{ type: Schema.Types.ObjectId, ref: 'User' }] 6 members: [{ type: Schema.Types.ObjectId, ref: 'User' }]
7 +},{
8 + collection: 'group'
7 }); 9 });
8 10
9 const Group = mongoose.model('Group',GroupSchema); 11 const Group = mongoose.model('Group',GroupSchema);
......
...@@ -5,6 +5,8 @@ const { Schema } = mongoose; ...@@ -5,6 +5,8 @@ const { Schema } = mongoose;
5 const ParticipationSchema = new Schema({ 5 const ParticipationSchema = new Schema({
6 sessionId: { type: Schema.Types.ObjectId, ref: 'Session' }, 6 sessionId: { type: Schema.Types.ObjectId, ref: 'Session' },
7 groupId: { type: Schema.Types.ObjectId, ref: 'Group' } 7 groupId: { type: Schema.Types.ObjectId, ref: 'Group' }
8 +},{
9 + collection: 'particiaption'
8 }); 10 });
9 11
10 const Participation = mongoose.model('Participation', ParticipationSchema); 12 const Participation = mongoose.model('Participation', ParticipationSchema);
......
...@@ -10,6 +10,8 @@ const ProblemSchema=new Schema({ ...@@ -10,6 +10,8 @@ const ProblemSchema=new Schema({
10 correctNum: {type: Number, required: true}, 10 correctNum: {type: Number, required: true},
11 count: { type: Number }, 11 count: { type: Number },
12 category: {type:[String]} 12 category: {type:[String]}
13 +},{
14 + collection: 'problem'
13 }); 15 });
14 16
15 ProblemSchema.statics.findByProblemNum=function(problemNum){ 17 ProblemSchema.statics.findByProblemNum=function(problemNum){
...@@ -59,5 +61,5 @@ ProblemSchema.methods.serialize=function(){ ...@@ -59,5 +61,5 @@ ProblemSchema.methods.serialize=function(){
59 return this.toJSON(); 61 return this.toJSON();
60 } 62 }
61 63
62 -const Problem=mongoose.model('Problem',ProblemSchema);
63 -module.exports=Problem;
...\ No newline at end of file ...\ No newline at end of file
64 +const Problem = mongoose.model('Problem',ProblemSchema);
65 +module.exports = Problem;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -5,7 +5,10 @@ const { Schema } = mongoose; ...@@ -5,7 +5,10 @@ const { Schema } = mongoose;
5 const SessionSchema = new Schema({ 5 const SessionSchema = new Schema({
6 challengeId: { type: Schema.Types.ObjectId, ref: 'Challenge' }, 6 challengeId: { type: Schema.Types.ObjectId, ref: 'Challenge' },
7 sessionStartDate: { type: Object }, 7 sessionStartDate: { type: Object },
8 - sessionEndDate: { type: Object } 8 + sessionEndDate: { type: Object },
9 + isOpen: { type: Boolean }
10 +},{
11 + collection: 'session'
9 }); 12 });
10 13
11 const Session = mongoose.model('Session', SessionSchema); 14 const Session = mongoose.model('Session', SessionSchema);
......
...@@ -13,6 +13,8 @@ const UserSchema = new Schema({ ...@@ -13,6 +13,8 @@ const UserSchema = new Schema({
13 friendList: [{ type: Schema.Types.ObjectId, ref: 'User' }], 13 friendList: [{ type: Schema.Types.ObjectId, ref: 'User' }],
14 slackWebHookURL: String, 14 slackWebHookURL: String,
15 goalNum: Number, 15 goalNum: Number,
16 +},{
17 + collection: 'user'
16 }); 18 });
17 19
18 UserSchema.statics.findByUsername = function (username) { 20 UserSchema.statics.findByUsername = function (username) {
......