challenges: add group.memberCount and ability to specifiy field projections in GET request /api/v1/groups?type=guild&fields=name,description,chat
This commit is contained in:
@@ -26,6 +26,8 @@ var GroupSchema = new Schema({
|
||||
# }]
|
||||
*/
|
||||
|
||||
memberCount: {type: Number, 'default': 0},
|
||||
challengeCount: {type: Number, 'default': 0},
|
||||
balance: Number,
|
||||
logo: String,
|
||||
leaderMessage: String,
|
||||
@@ -59,6 +61,8 @@ function removeDuplicates(doc){
|
||||
|
||||
GroupSchema.pre('save', function(next){
|
||||
removeDuplicates(this);
|
||||
this.memberCount = _.size(this.members);
|
||||
this.challengeCount = _.size(this.challenges);
|
||||
next();
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user