Showing
5 changed files
with
14 additions
and
6 deletions
... | @@ -9,9 +9,17 @@ const GroupSchema = new Schema({ | ... | @@ -9,9 +9,17 @@ const GroupSchema = new Schema({ |
9 | }); | 9 | }); |
10 | 10 | ||
11 | GroupSchema.methods.addGroupMemeber=function(user){ | 11 | GroupSchema.methods.addGroupMemeber=function(user){ |
12 | - this.members.push({$oid:user._id.$oid}); | 12 | + this.members.push(user._id); |
13 | return this.save(); | 13 | return this.save(); |
14 | } | 14 | } |
15 | 15 | ||
16 | +GroupSchema.methods.getMembers=function(){ | ||
17 | + return this.members; | ||
18 | +} | ||
19 | + | ||
20 | +GroupSchema.methods.serialize=function(){ | ||
21 | + return this.toJSON(); | ||
22 | +} | ||
23 | + | ||
16 | const Group = mongoose.model('Group',GroupSchema); | 24 | const Group = mongoose.model('Group',GroupSchema); |
17 | module.exports = Group; | 25 | module.exports = Group; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -18,11 +18,11 @@ const ParticipationSchema = new Schema({ | ... | @@ -18,11 +18,11 @@ const ParticipationSchema = new Schema({ |
18 | }); | 18 | }); |
19 | 19 | ||
20 | ParticipationSchema.statics.findBySessionId=function(session){ | 20 | ParticipationSchema.statics.findBySessionId=function(session){ |
21 | - return this.find({sessionId:session._id.$oid}); | 21 | + return this.find({sessionId:session._id}); |
22 | } | 22 | } |
23 | 23 | ||
24 | ParticipationSchema.statics.findByGroupId=function(group){ | 24 | ParticipationSchema.statics.findByGroupId=function(group){ |
25 | - return this.find({groupId:group._id.$oid}); | 25 | + return this.find({groupId:group._id}); |
26 | } | 26 | } |
27 | 27 | ||
28 | ParticipationSchema.methods.addProblem=function(problem){ | 28 | ParticipationSchema.methods.addProblem=function(problem){ | ... | ... |
... | @@ -9,7 +9,7 @@ const ProblemSchema=new Schema({ | ... | @@ -9,7 +9,7 @@ const ProblemSchema=new Schema({ |
9 | sumbitNum: {type: Number, required: true}, | 9 | sumbitNum: {type: Number, required: true}, |
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 | },{ | 13 | },{ |
14 | collection: 'problem' | 14 | collection: 'problem' |
15 | }); | 15 | }); | ... | ... |
... | @@ -12,7 +12,7 @@ const SessionSchema = new Schema({ | ... | @@ -12,7 +12,7 @@ const SessionSchema = new Schema({ |
12 | }); | 12 | }); |
13 | 13 | ||
14 | SessionSchema.statics.findByChallengeId=function(challenge){ | 14 | SessionSchema.statics.findByChallengeId=function(challenge){ |
15 | - return this.find({challengeId:challenge._id.$oid}); | 15 | + return this.find({challengeId:challenge._id}); |
16 | } | 16 | } |
17 | 17 | ||
18 | SessionSchema.methods.getSessionStartDate=function(){ | 18 | SessionSchema.methods.getSessionStartDate=function(){ | ... | ... |
... | @@ -22,7 +22,7 @@ UserSchema.statics.findByUsername = function (username) { | ... | @@ -22,7 +22,7 @@ UserSchema.statics.findByUsername = function (username) { |
22 | }; | 22 | }; |
23 | 23 | ||
24 | UserSchema.methods.addFriend=function(friend){ | 24 | UserSchema.methods.addFriend=function(friend){ |
25 | - this.friendList.push({$oid:friend._id.$oid}); | 25 | + this.friendList.push(friend._id); |
26 | return this.save(); | 26 | return this.save(); |
27 | } | 27 | } |
28 | 28 | ... | ... |
-
Please register or login to post a comment