Added achievement model and some missing pieces

This commit is contained in:
Ruben Vereecken 2014-05-19 23:20:50 +02:00
parent 1b2a251c58
commit c26f96f33e
4 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,6 @@
CocoModel = require './CocoModel'
module.exports = class Achievement extends CocoModel
@className: 'Achievement'
@schema: require 'schemas/models/achievement'
urlRoot: '/db/achievement'

View file

@ -31,6 +31,7 @@ module.exports = class SearchView extends View
'shown.bs.modal #new-model-modal': 'focusOnName'
'hidden.bs.modal #new-model-modal': 'onModalHidden'
constructor: (options) ->
@runSearch = _.debounce(@runSearch, 500)
super options

View file

@ -1,4 +1,5 @@
mongoose = require('mongoose')
plugins = require('../plugins/plugins')
jsonschema = require('../../app/schemas/models/achievement')
# `pre` and `post` are not called for update operations executed directly on the database,
@ -10,4 +11,7 @@ AchievementSchema = new mongoose.Schema({
query: Object
}, {strict: false})
AchievementSchema.plugin(plugins.SearchablePlugin, {searchable: ['name']})
AchievementSchema.plugin(plugins.NamedPlugin)
module.exports = Achievement = mongoose.model('Achievement', AchievementSchema)

View file

@ -153,10 +153,10 @@ module.exports = class Handler
return @sendDatabaseError(res, err) if err
@sendSuccess(res, @formatEntity(req, document))
# project=true or project=name,description,slug for example
search: (req, res) ->
unless @modelClass.schema.uses_coco_search
return @sendNotFoundError(res)
term = req.query.term
matchedObjects = []
filters = [{filter: {index: true}}]