filter

Specifies the filter expression when applying a filter data transformation. The filter setting can be specified in one of the following formats:

1. As an object literal specifying filtration by a single data field (i.e. simple filter):

var dataSource = new shield.DataSource({
    filter: { path: "category", filter: "eq", value: 3 }
});

2. As an array of object literals, where each item specifies a single data field to filter by (i.e. array of simple filters). The result of filtration is formed by applying all the specified simple filters with the AND logical operation:

var dataSource = new shield.DataSource({
    filter: [
        { path: "category", filter: "eq", value: 3 },
        { path: "price", filter: "lt", value: 12 }
    ]
});

3. As a compound object literal specifying multiple simple filters and the logical operations between them (i.e. compound filter):

var dataSource = new shield.DataSource({
    filter: {
        or: [
            { path: "category", filter: "eq", value: 3 },
            { path: "price", filter: "lt", value: 12 }
        ]
    }
});

4. As a function expression specifying the filter function to use:

var dataSource = new shield.DataSource({
    filter: function (item) {
        return item.category == 3 || item.price < 12;
    }
});

The filter function is called once for every item in the data array, providing the data item as a first argument. The function must return a boolean value indicating whether the specified item is to be included in the result set. The filter function is semantically equivalent to Array.prototype.filter().