text: 'use strict';
  
  var actionUtil = require('sails/lib/hooks/blueprints/actionUtil');
  
  /**
   * BaseController.js
   *
   * Base controller for all sails.js controllers. This just contains some common code
   * that every controller uses
   */
  module.exports = {
    /**
     * Generic count action for controller.
     *
     * @param   {Request}   req
     * @param   {Response}  res
     */
    count: function count(req, res) {
  
      var parseBlueprintOptions = req.options.parseBlueprintOptions || req._sails.config.blueprints.parseBlueprintOptions;
  
      // Set the blueprint action for parseBlueprintOptions.
      req.options.blueprintAction = 'count';
  
      var queryOptions = parseBlueprintOptions(req);
  
      var Model = req._sails.models[queryOptions.using];
  
      Model
        .count(actionUtil.parseCriteria(req))
        .exec(function found(error, count) {
          if (error) {
            res.serverError(error);
          } else {
            res.ok({count: count});
          }
        })
      ;
    }
  };
  