api/services/PermissionService.js
function(req) {


    // handle add/remove routes that have :parentid as the primary key field
    var originalId;
    if (req.params.parentid) {
      originalId = req.params.id;
      req.params.id = req.params.parentid;
    }

    return new Promise(function(resolve, reject) {
        sails.hooks.blueprints.middleware.find(req, {
          ok: resolve,
          serverError: reject,
          // this isn't perfect, since it returns a 500 error instead of a 404 error
          // but it is better than crashing the app when a record doesn't exist
          notFound: reject
        });
      })
      .then(function(result) {
        if (originalId !== undefined) {
          req.params.id = originalId;
        }
        return result;
      });
  }
function(req) {


    // handle add/remove routes that have :parentid as the primary key field
    var originalId;
    if (req.params.parentid) {
      originalId = req.params.id;
      req.params.id = req.params.parentid;
    }

    return new Promise(function(resolve, reject) {
        sails.hooks.blueprints.middleware.find(req, {
          ok: resolve,
          serverError: reject,
          // this isn't perfect, since it returns a 500 error instead of a 404 error
          // but it is better than crashing the app when a record doesn't exist
          notFound: reject
        });
      })
      .then(function(result) {
        if (originalId !== undefined) {
          req.params.id = originalId;
        }
        return result;
      });
  }
function ( req ) { // handle add/remove routes that have :parentid as the primary key field var originalId ; if ( req . params . parentid ) { originalId = req . params . id ; req . params . id = req . params . parentid ; } return new Promise ( function ( resolve , reject ) { sails . hooks . blueprints . middleware . find ( req , { ok : resolve , serverError : reject , // this isn't perfect, since it returns a 500 error instead of a 404 error // but it is better than crashing the app when a record doesn't exist notFound : reject } ) ; } ) . then ( function ( result ) { if ( originalId !== undefined ) { req . params . id = originalId ; } return result ; } ) ; }
Find objects that some arbitrary action would be performed on, given the
same request.

@param options.model
@param options.query

TODO this will be less expensive when waterline supports a caching layer
Find objects that some arbitrary action would be performed on given the same request .