Skip to content

Commit

Permalink
Extracting List.prototype.processFilters & adding deprecation note
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Aug 8, 2015
1 parent b412c59 commit 8b1867d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
19 changes: 1 addition & 18 deletions lib/list.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var _ = require('underscore');
var keystone = require('../');
var moment = require('moment');
var queryfilterlib = require('queryfilter');
var schemaPlugins = require('./schemaPlugins');
var utils = require('keystone-utils');

Expand Down Expand Up @@ -127,6 +126,7 @@ List.prototype.addFiltersToQuery = require('./list/addFiltersToQuery');
List.prototype.isReserved = require('./list/isReserved');
List.prototype.expandColumns = require('./list/expandColumns');
List.prototype.selectColumns = require('./list/selectColumns');
List.prototype.processFilters = require('./list/processFilters');


/**
Expand Down Expand Up @@ -182,23 +182,6 @@ Object.defineProperty(List.prototype, 'defaultColumns', {
});


/**
* Processes a filter string into a filters object
*
* @param {String} filters
*/
List.prototype.processFilters = function(q) {
var list = this;
var filters = {};
queryfilterlib.QueryFilters.create(q).getFilters().forEach(function(filter){
filter.path = filter.key; // alias for b/c
filter.field = list.fields[filter.key];
filters[filter.path] = filter;
});
return filters;
};


/**
* Gets filters for a Mongoose query that will search for the provided string,
* based on the searchFields List option.
Expand Down
22 changes: 22 additions & 0 deletions lib/list/processFilters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var queryfilterlib = require('queryfilter');

/**
* Processes a filter string into a filters object
*
* NOTE: This function is deprecated in favor of List.prototype.addFiltersToQuery
* and will be removed in a later version.
*
* @param {String} filters
*/
function processFilters (q) {
var list = this;
var filters = {};
queryfilterlib.QueryFilters.create(q).getFilters().forEach(function(filter){
filter.path = filter.key; // alias for b/c
filter.field = list.fields[filter.key];
filters[filter.path] = filter;
});
return filters;
}

module.exports = processFilters;

0 comments on commit 8b1867d

Please sign in to comment.