2015-03-07 19:30:25 -05:00
|
|
|
mongoose = require 'mongoose'
|
|
|
|
plugins = require '../plugins/plugins'
|
|
|
|
jsonSchema = require '../../app/schemas/models/poll.schema'
|
|
|
|
log = require 'winston'
|
|
|
|
|
|
|
|
PollSchema = new mongoose.Schema {
|
|
|
|
created:
|
|
|
|
type: Date
|
|
|
|
'default': Date.now
|
2015-03-20 16:33:03 -04:00
|
|
|
}, {strict: false, minimize: false,read:'nearest'}
|
2015-03-07 19:30:25 -05:00
|
|
|
|
|
|
|
PollSchema.index {priority: 1}
|
|
|
|
|
|
|
|
# Just duplicating indexes that get created here by plugins for completeness
|
|
|
|
PollSchema.index {i18nCoverage: 1}, {name: 'translation coverage index', sparse: true}
|
|
|
|
PollSchema.index {slug: 1}, {name: 'slug index', sparse: true, unique: true}
|
|
|
|
|
|
|
|
PollSchema.plugin plugins.NamedPlugin
|
|
|
|
PollSchema.plugin plugins.PatchablePlugin
|
|
|
|
PollSchema.plugin plugins.TranslationCoveragePlugin
|
|
|
|
PollSchema.plugin plugins.SearchablePlugin, {searchable: ['name', 'description']}
|
|
|
|
|
|
|
|
PollSchema.statics.privateProperties = []
|
|
|
|
PollSchema.statics.editableProperties = [
|
|
|
|
'name'
|
|
|
|
'description'
|
|
|
|
'answers'
|
|
|
|
'i18n'
|
|
|
|
'i18nCoverage'
|
|
|
|
'priority'
|
2015-03-09 12:30:51 -04:00
|
|
|
'userProperty'
|
2015-03-07 19:30:25 -05:00
|
|
|
]
|
|
|
|
PollSchema.statics.jsonSchema = jsonSchema
|
|
|
|
|
|
|
|
module.exports = Poll = mongoose.model 'poll', PollSchema, 'polls'
|