# all files / keystone/lib/list/ processFilters.js

30% Statements 3/10
100% Branches 0/0
0% Functions 0/2
30% Lines 3/10

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    231×

    1×

    1×
     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;