What this is about
A table does not show 10,000 customers at once, but 25 per page. For this there are two settings in parameter:
| Setting | Meaning | Default |
|---|---|---|
limit | the maximum number of objects on one page | -1 = all |
page | which page, counted from 0 | 0 |
Page page starts at match number page × limit. With limit: 25, page: 0 is matches 1–25, page: 1 is matches 26–50.
The pagination bar
flowchart LR
subgraph T["totalCount = 60, limit = 25"]
direction LR
p0["page 0<br/>matches 1–25"]
p1["page 1<br/>matches 26–50"]
p2["page 2<br/>matches 51–60"]
end
p0 --> p1 --> p2
You calculate the number of pages from totalCount and limit: round up totalCount / limit. With 60 matches and limit 25, that is 3 pages.
What is in meta
POST /api/rest/preset/query
{ "response": ["label"],
"parameter": { "limit": 2, "page": 1,
"order": [{ "field": "amount", "order": "ASC" }] } }{
"data": [ { "label": "Gamma" } ],
"meta": {
"error": false,
"totalCount": 3,
"currentPage": 1,
"currentLimit": 2,
"currentPageSize": 1
}
}| Field | Meaning |
|---|---|
totalCount | number of all matches across all pages, after all filters |
currentPage | the requested page |
currentLimit | the requested limit |
currentPageSize | helper value of the page calculation. For the pagination bar, calculate the number of pages yourself from totalCount and limit. |
error | always false for a successful search |
CDMS calculates totalCount with a separate count query before it reads the page. The number takes the same filters into account as the matches, including the filters that always run along. So two users can see a different totalCount for the same search.
All variants
When: A table with pages.
"limit": 25, "page": 0 returns the first 25, plus totalCount for the pagination bar.
Result: At most 25 objects.
When: You really need all of them, for example for an export or a selection list with few entries.
"limit": -1 or leave out limit. page does not matter then.
Result: All matches at once.
When: You only want to know how many matches there are.
"limit": 0 returns no objects, but it returns totalCount.
Result: data is empty, totalCount is correct.
When: "page": 5 with only 3 matches and limit 2.
No error.
Result: data is empty, totalCount is correct.
When: "page": -1
CDMS returns the first page. meta.currentPage holds the requested value.
Result: Same as page 0.
When: "meta": true (default) or false.
For a search on a normal model, meta with totalCount comes back in both cases.
Result: totalCount is always there.
When: A search via the hub API of an abstract model.
totalCount comes from the first phase on the parent model, together with filter, sorting and page. See Abstract models and @type.
Result: One number for all subtypes together.