mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 02:55:43 -05:00
aecf937722
Made sure server sided tests work completely
27 lines
680 B
CoffeeScript
27 lines
680 B
CoffeeScript
mongoose = require 'mongoose'
|
|
jsonschema = require '../../app/schemas/models/earned_achievement'
|
|
|
|
EarnedAchievementSchema = new mongoose.Schema({
|
|
created:
|
|
type: Date
|
|
default: Date.now
|
|
changed:
|
|
type: Date
|
|
default: Date.now
|
|
notified:
|
|
type: Boolean
|
|
default: false
|
|
}, {strict:false})
|
|
|
|
EarnedAchievementSchema.pre 'save', (next) ->
|
|
@set('changed', Date.now())
|
|
next()
|
|
|
|
EarnedAchievementSchema.index({user: 1, achievement: 1}, {unique: true, name: 'earned achievement index'})
|
|
EarnedAchievementSchema.index({user: 1, changed: -1}, {name: 'latest '})
|
|
|
|
|
|
module.exports = EarnedAchievement = mongoose.model('EarnedAchievement', EarnedAchievementSchema)
|
|
|
|
|
|
|