filterMembersAndGetCount
Filter data using a query and get the number of records that would be returned without pagination.
queryLogic.filterMembersAndGetCount(a, [b,] bData)
filterMembersAndGetCount is just like filterMembers, except it
includes a count of the number of records that would be returned if the pagination properties were
removed.
In the following example, notice how there are 3 records of {type: "dog"} in the source data, but
only two records are provided in data:
import {QueryLogic} from "can";
const queryLogic = new QueryLogic();
const filtered = queryLogic.filterMembersAndGetCount(
{filter: {type: "dog"}, page: {start: 0, end: 1}},
{},
[
{id: 1, type:"cat"},
{id: 2, type: "dog"},
{id: 3, type: "dog"},
{id: 4, type: "zebra"},
{id: 5, type: "dog"}
]
);
console.log( filtered ); //-> {data: [{id: 2, type: "dog"},{id: 3, type: "dog"}], count: 3}
Parameters
Returns
{Object}:
An object like: {count: Number, data: [...]} where:
countis the number of unpaginated resultsdatais the filtered and paginated records