Skip to content

Commit

Permalink
Optimising List.prototype.addSearchToQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Aug 17, 2015
1 parent dc7a5f5 commit 479ffa1
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/list/addSearchToQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,12 @@ function addSearchToQuery (searchString, query) {
query = query || {};
if (!searchString) return query;

var searchFields = listToArray(this.get('searchFields'));
var searchRegExp = new RegExp(utils.escapeRegExp(searchString), 'i');

var searchFilters = searchFields.map(function (path) {
if (path === '__name__') {
path = this.mappings.name;
}
var field = this.fields[path];
if (field && field.type === 'name') {
return getNameFilter(field, searchString);
var searchFilters = this.searchFields.map(function (i) {
if (i.field && i.field.type === 'name') {
return getNameFilter(i.field, searchString);
} else {
return getStringFilter(path, searchRegExp);
return getStringFilter(i.path, searchRegExp);
}
}, this);

Expand Down

0 comments on commit 479ffa1

Please sign in to comment.