Search...
skip( )
Sets the number of items or groups to skip before returning aggregation results.
Description
The skip()
function defines the number of results to skip in the aggregation
results before returning new aggregation results.
For example, if you perform an aggregation on a collection and 10 groups match
your aggregation, but you set skip
to 3, the results returned will skip
the first 3 groups that match and return the 4th through 10th items.
By default, skip
is set to 0.
Note: Aggregations can only be used on collections you have created. They cannot be used on Wix App Collections.
Syntax
function skip(skip: number): WixDataAggregate
skip Parameters
NAME
TYPE
DESCRIPTION
skip
number
The number of items or groups to skip in the aggregation results before returning the results.
Was this helpful?
Add a skip to an aggregation
Copy Code
1let newAggregate = aggregate.skip(10);
Create an aggregate, add a skip, and run it
Copy Code
1import wixData from 'wix-data';23// ...45wixData.aggregate("PopulationData")6 .group("state", "year")7 .max("population")8 .skip(3)9 .run()10 .then((results) => {11 if (results.items.length > 0) {12 let items = results.items; // see below13 let numItems = results.length; // 314 let hasNext = results.hasNext();15 } else {16 // handle case where no matching items found17 }18 })19 .catch((error) => {20 let errorMsg = error.message;21 let code = error.code;22 });2324/* Given the sample data above, items is:25 * [26 * {27 * "_id": {"state": "FL", "year": 2010},28 * "populationMax":401000,29 * "state": "FL",30 * "year": 201031 * }, {32 * "_id": {"state": "CA", "year": 2010},33 * "populationMax":3796000,34 * "state": "CA",35 * "year": 201036 * }, {37 * "_id": {"state": "NY", "year": 2010},38 * "populationMax":8192000,39 * "state": "NY",40 * "year": 201041 * }42 * ]43 */
Create an aggregation with filtering and grouping and run it
Copy Code
1import wixData from 'wix-data';23// ...45const filter = wixData.filter().eq("year", 2010);6const having = wixData.filter().gt("maxPopulation", 1000000);78wixData.aggregate("PopulationData")9 .filter(filter)10 .group("state")11 .max("population", "maxPopulation")12 .having(having)13 .descending("maxPopulation")14 .skip(5)15 .limit(3)16 .run()17 .then((results) => {18 if (results.items.length > 0) {19 let items = results.items;20 let numItems = results.length;21 let hasNext = results.hasNext();22 } else {23 // handle case where no matching items found24 }25 })26 .catch((error) => {27 let errorMsg = error.message;28 let code = error.code;29 });