mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-18 03:23:42 -05:00
ae82875c57
When a new version is created, the latest version is updated, then the new one is made. If making a new one fails (most commonly due to a name conflict), the latest version is left in a broken state. Set up the new middleware to revert changes to latest version in this case, and update the level handler to use the middleware. Also added warning logs if models do not have editableProperties or postEditableProperties set.
35 lines
895 B
CoffeeScript
35 lines
895 B
CoffeeScript
mongoose = require 'mongoose'
|
|
config = require '../../server_config'
|
|
|
|
CodeLogSchema = new mongoose.Schema({
|
|
created:
|
|
type: Date
|
|
default: Date.now
|
|
userID:
|
|
type: mongoose.Schema.ObjectId
|
|
sessionID:
|
|
type: mongoose.Schema.ObjectId
|
|
level:
|
|
original:
|
|
type: mongoose.Schema.ObjectId
|
|
majorVersion:
|
|
type: Number
|
|
default: 0
|
|
}, {strict: false, read: config.mongo.readpref})
|
|
|
|
CodeLogSchema.index({levelSlug: 1, created: -1}, {name: 'level slug index'})
|
|
CodeLogSchema.index({userID: 1, created: -1}, {name: 'user id index'})
|
|
|
|
CodeLogSchema.statics.editableProperties = [
|
|
'sessionID'
|
|
'level'
|
|
'levelSlug'
|
|
'userID'
|
|
'log'
|
|
'created'
|
|
]
|
|
CodeLogSchema.statics.postEditableProperties = []
|
|
|
|
CodeLogSchema.statics.jsonSchema = require '../../app/schemas/models/codelog.schema'
|
|
|
|
module.exports = CodeLog = mongoose.model('CodeLog', CodeLogSchema, 'codelogs')
|