diff --git a/server/achievements/Achievement.coffee b/server/achievements/Achievement.coffee index f6f26bbed..4ca286e71 100644 --- a/server/achievements/Achievement.coffee +++ b/server/achievements/Achievement.coffee @@ -31,6 +31,7 @@ AchievementSchema.index( }) AchievementSchema.index({i18nCoverage: 1}, {name: 'translation coverage index', sparse: true}) AchievementSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true}) +AchievementSchema.index({related: 1}, {name: 'related index', sparse: true}) AchievementSchema.methods.objectifyQuery = -> try diff --git a/server/campaigns/Campaign.coffee b/server/campaigns/Campaign.coffee index 65a7ef614..20f8ca699 100644 --- a/server/campaigns/Campaign.coffee +++ b/server/campaigns/Campaign.coffee @@ -7,6 +7,7 @@ CampaignSchema = new mongoose.Schema(body: String, {strict: false,read:config.mo CampaignSchema.index({i18nCoverage: 1}, {name: 'translation coverage index', sparse: true}) CampaignSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true}) +CampaignSchema.index({type: 1}, {name: 'type index', sparse: true}) CampaignSchema.plugin(plugins.NamedPlugin) CampaignSchema.plugin(plugins.TranslationCoveragePlugin) diff --git a/server/classrooms/Classroom.coffee b/server/classrooms/Classroom.coffee index 6478dab8b..c33fceb41 100644 --- a/server/classrooms/Classroom.coffee +++ b/server/classrooms/Classroom.coffee @@ -7,6 +7,10 @@ jsonSchema = require '../../app/schemas/models/classroom.schema' ClassroomSchema = new mongoose.Schema {}, {strict: false, minimize: false, read:config.mongo.readpref} +ClassroomSchema.index({ownerID: 1}, {name: 'ownerID index'}) +ClassroomSchema.index({members: 1}, {name: 'members index'}) +ClassroomSchema.index({code: 1}, {name: 'code index', unique: true}) + ClassroomSchema.statics.privateProperties = [] ClassroomSchema.statics.editableProperties = [ 'description' diff --git a/server/commons/Handler.coffee b/server/commons/Handler.coffee index 5015439f6..dd61bd62e 100644 --- a/server/commons/Handler.coffee +++ b/server/commons/Handler.coffee @@ -501,9 +501,9 @@ module.exports = class Handler if Handler.isID(idOrSlug) query = @modelClass.findById(idOrSlug) else - if not idOrSlug or idOrSlug is 'undefined' - console.error "What? Why are we fetching the slug: #{idOrSlug}?" - console.trace() + if not idOrSlug or idOrSlug is 'undefined' + console.error "What? Why are we fetching the slug: #{idOrSlug}?" + console.trace() query = @modelClass.findOne {slug: idOrSlug} query.select projection if projection query.exec (err, document) ->