       query['version.major'] = majorVersion unless _.isNaN(majorVersion)
       query['version.minor'] = minorVersion unless _.isNaN(minorVersion)
     sort = { 'version.major': -1, 'version.minor': -1 }
-    @modelClass.findOne(query).sort(sort).exec (err, doc) =>
+    args = [query]
+    args.push PROJECT if req.query.project
+    @modelClass.findOne(args...).sort(sort).exec (err, doc) =>
       return @sendNotFoundError(res) unless doc?
       return @sendUnauthorizedError(res) unless @hasAccessToDocument(req, doc)
       res.send(doc)

    unless @modelClass.schema.uses_coco_search
      return @sendNotFoundError(res)

    project = {original:1, name:1, version:1, description: 1, slug:1, kind: 1}
    term = req.query.term
    matchedObjects = []
    filters = [{filter: {index: true}}]

mongoose = require('mongoose')
Grid = require 'gridfs-stream'
errors = require './errors'
PROJECT = {original:1, name:1, version:1, description: 1, slug:1, kind: 1}

module.exports = class Handler
  # subclasses should override these properties
