Add Classroom, Clan, and Achievement indexes. Fix logging for undefined slugs indentation.

This commit is contained in:
Nick Winter 2015-12-03 11:15:34 -08:00
parent b3edafe285
commit e3db0dea3a
4 changed files with 9 additions and 3 deletions

View file

@ -31,6 +31,7 @@ AchievementSchema.index(
}) })
AchievementSchema.index({i18nCoverage: 1}, {name: 'translation coverage index', sparse: true}) AchievementSchema.index({i18nCoverage: 1}, {name: 'translation coverage index', sparse: true})
AchievementSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true}) AchievementSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
AchievementSchema.index({related: 1}, {name: 'related index', sparse: true})
AchievementSchema.methods.objectifyQuery = -> AchievementSchema.methods.objectifyQuery = ->
try try

View file

@ -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({i18nCoverage: 1}, {name: 'translation coverage index', sparse: true})
CampaignSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: 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.NamedPlugin)
CampaignSchema.plugin(plugins.TranslationCoveragePlugin) CampaignSchema.plugin(plugins.TranslationCoveragePlugin)

View file

@ -7,6 +7,10 @@ jsonSchema = require '../../app/schemas/models/classroom.schema'
ClassroomSchema = new mongoose.Schema {}, {strict: false, minimize: false, read:config.mongo.readpref} 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.privateProperties = []
ClassroomSchema.statics.editableProperties = [ ClassroomSchema.statics.editableProperties = [
'description' 'description'

View file

@ -501,9 +501,9 @@ module.exports = class Handler
if Handler.isID(idOrSlug) if Handler.isID(idOrSlug)
query = @modelClass.findById(idOrSlug) query = @modelClass.findById(idOrSlug)
else else
if not idOrSlug or idOrSlug is 'undefined' if not idOrSlug or idOrSlug is 'undefined'
console.error "What? Why are we fetching the slug: #{idOrSlug}?" console.error "What? Why are we fetching the slug: #{idOrSlug}?"
console.trace() console.trace()
query = @modelClass.findOne {slug: idOrSlug} query = @modelClass.findOne {slug: idOrSlug}
query.select projection if projection query.select projection if projection
query.exec (err, document) -> query.exec (err, document) ->