Added an endpoint for loading all items.

This commit is contained in:
Scott Erickson 2014-08-12 10:09:53 -07:00
parent d3fb168636
commit 04e8680263

View file

@ -26,4 +26,16 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
hasAccess: (req) ->
req.method is 'GET' or req.user?.isAdmin()
get: (req, res) ->
if req.query.view is 'items'
projection = {}
if req.query.project
projection[field] = 1 for field in req.query.project.split(',')
ThangType.find({ 'kind': 'Item' }, projection).exec (err, documents) =>
return @sendDatabaseError(res, err) if err
documents = (@formatEntity(req, doc) for doc in documents)
@sendSuccess(res, documents)
else
super(arguments...)
module.exports = new ThangTypeHandler()