2015-03-07 19:30:25 -05:00
|
|
|
mongoose = require 'mongoose'
|
|
|
|
plugins = require '../plugins/plugins'
|
2016-04-06 13:56:06 -04:00
|
|
|
jsonSchema = require '../../app/schemas/models/poll.schema.coffee'
|
2015-03-07 19:30:25 -05:00
|
|
|
log = require 'winston'
|
2015-03-21 21:49:32 -04:00
|
|
|
config = require '../../server_config'
|
2015-03-07 19:30:25 -05:00
|
|
|
PollSchema = new mongoose.Schema {
|
|
|
|
created:
|
|
|
|
type: Date
|
|
|
|
'default': Date.now
|
2015-03-21 21:49:32 -04:00
|
|
|
}, {strict: false, minimize: false,read:config.mongo.readpref}
|
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'
|