templates/advanced/api/blueprints/_util/actionUtil.js
function ( req ) {

		// Allow customizable blacklist for params NOT to include as criteria.
		req.options.criteria = req.options.criteria || {};
		req.options.criteria.blacklist = req.options.criteria.blacklist || [ 'limit', 'skip', 'sort', 'populate' ];

		// Validate blacklist to provide a more helpful error msg.
		var blacklist = req.options.criteria && req.options.criteria.blacklist;
		if ( blacklist && !_.isArray( blacklist ) ) {
			throw new Error( 'Invalid `req.options.criteria.blacklist`. Should be an array of strings (parameter names.)' );
		}

		// Look for explicitly specified `where` parameter.
		var where = req.params.all().where;

		// If `where` parameter is a string, try to interpret it as JSON
		if ( _.isString( where ) ) {
			where = tryToParseJSON( where );
		}

		// If `where` has not been specified, but other unbound parameter variables
		// **ARE** specified, build the `where` option using them.
		if ( !where ) {

			// Prune params which aren't fit to be used as `where` criteria
			// to build a proper where query
			where = req.params.all();

			// Omit built-in runtime config (like query modifiers)
			where = _.omit( where, blacklist || [ 'limit', 'skip', 'sort' ] );

			// Omit any params w/ undefined values
			where = _.omit( where, function ( p ) {
				if ( _.isUndefined( p ) ) return true;
			} );

			// Transform ids[ .., ..] request
			if ( where.ids ) {
				where.id = where.ids;
				delete where.ids;
			}

			// Omit jsonp callback param (but only if jsonp is enabled)
			var jsonpOpts = req.options.jsonp && !req.isSocket;
			jsonpOpts = _.isObject( jsonpOpts ) ? jsonpOpts : {
				callback: JSONP_CALLBACK_PARAM
			};
			if ( jsonpOpts ) {
				where = _.omit( where, [ jsonpOpts.callback ] );
			}
		}

		// Merge w/ req.options.where and return
		where = _.merge( {}, req.options.where || {}, where ) || undefined;

		return where;
	}
function ( req ) {

		// Allow customizable blacklist for params NOT to include as criteria.
		req.options.criteria = req.options.criteria || {};
		req.options.criteria.blacklist = req.options.criteria.blacklist || [ 'limit', 'skip', 'sort', 'populate' ];

		// Validate blacklist to provide a more helpful error msg.
		var blacklist = req.options.criteria && req.options.criteria.blacklist;
		if ( blacklist && !_.isArray( blacklist ) ) {
			throw new Error( 'Invalid `req.options.criteria.blacklist`. Should be an array of strings (parameter names.)' );
		}

		// Look for explicitly specified `where` parameter.
		var where = req.params.all().where;

		// If `where` parameter is a string, try to interpret it as JSON
		if ( _.isString( where ) ) {
			where = tryToParseJSON( where );
		}

		// If `where` has not been specified, but other unbound parameter variables
		// **ARE** specified, build the `where` option using them.
		if ( !where ) {

			// Prune params which aren't fit to be used as `where` criteria
			// to build a proper where query
			where = req.params.all();

			// Omit built-in runtime config (like query modifiers)
			where = _.omit( where, blacklist || [ 'limit', 'skip', 'sort' ] );

			// Omit any params w/ undefined values
			where = _.omit( where, function ( p ) {
				if ( _.isUndefined( p ) ) return true;
			} );

			// Transform ids[ .., ..] request
			if ( where.ids ) {
				where.id = where.ids;
				delete where.ids;
			}

			// Omit jsonp callback param (but only if jsonp is enabled)
			var jsonpOpts = req.options.jsonp && !req.isSocket;
			jsonpOpts = _.isObject( jsonpOpts ) ? jsonpOpts : {
				callback: JSONP_CALLBACK_PARAM
			};
			if ( jsonpOpts ) {
				where = _.omit( where, [ jsonpOpts.callback ] );
			}
		}

		// Merge w/ req.options.where and return
		where = _.merge( {}, req.options.where || {}, where ) || undefined;

		return where;
	}
function ( req ) { // Allow customizable blacklist for params NOT to include as criteria. req . options . criteria = req . options . criteria || { } ; req . options . criteria . blacklist = req . options . criteria . blacklist || [ 'limit' , 'skip' , 'sort' , 'populate' ] ; // Validate blacklist to provide a more helpful error msg. var blacklist = req . options . criteria && req . options . criteria . blacklist ; if ( blacklist && ! _ . isArray ( blacklist ) ) { throw new Error ( 'Invalid `req.options.criteria.blacklist`. Should be an array of strings (parameter names.)' ) ; } // Look for explicitly specified `where` parameter. var where = req . params . all ( ) . where ; // If `where` parameter is a string, try to interpret it as JSON if ( _ . isString ( where ) ) { where = tryToParseJSON ( where ) ; } // If `where` has not been specified, but other unbound parameter variables // **ARE** specified, build the `where` option using them. if ( ! where ) { // Prune params which aren't fit to be used as `where` criteria // to build a proper where query where = req . params . all ( ) ; // Omit built-in runtime config (like query modifiers) where = _ . omit ( where , blacklist || [ 'limit' , 'skip' , 'sort' ] ) ; // Omit any params w/ undefined values where = _ . omit ( where , function ( p ) { if ( _ . isUndefined ( p ) ) return true ; } ) ; // Transform ids[ .., ..] request if ( where . ids ) { where . id = where . ids ; delete where . ids ; } // Omit jsonp callback param (but only if jsonp is enabled) var jsonpOpts = req . options . jsonp && ! req . isSocket ; jsonpOpts = _ . isObject ( jsonpOpts ) ? jsonpOpts : { callback : JSONP_CALLBACK_PARAM } ; if ( jsonpOpts ) { where = _ . omit ( where , [ jsonpOpts . callback ] ) ; } } // Merge w/ req.options.where and return where = _ . merge ( { } , req . options . where || { } , where ) || undefined ; return where ; }
Parse `criteria` for a Waterline `find` or `update` from all
request parameters.

@param	{Request} req
@return {Object}						the WHERE criteria object
Parse criteria for a Waterline find or update from all request parameters .