CodamAIDocs
Topicdone

Paging and match count

How page, limit and meta work together, why limit: -1 returns everything, and where totalCount comes from.

Variants
limit setlimit -1 (everything)limit 0page past the endnegative pagemetaabstract model

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:

SettingMeaningDefault
limitthe maximum number of objects on one page-1 = all
pagewhich page, counted from 00

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

Second page with two objects per page
Request
POST /api/rest/preset/query
{ "response": ["label"],
  "parameter": { "limit": 2, "page": 1,
                 "order": [{ "field": "amount", "order": "ASC" }] } }
Response
{
  "data": [ { "label": "Gamma" } ],
  "meta": {
    "error": false,
    "totalCount": 3,
    "currentPage": 1,
    "currentLimit": 2,
    "currentPageSize": 1
  }
}
FieldMeaning
totalCountnumber of all matches across all pages, after all filters
currentPagethe requested page
currentLimitthe requested limit
currentPageSizehelper value of the page calculation. For the pagination bar, calculate the number of pages yourself from totalCount and limit.
erroralways 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

page and limit in all forms

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.

Traps

Sources in the code and the knowledge base
  • CDMS/cdms-persistence-database – AbstractDatabasePersistence.queryObjects (count, page, fields)
  • CDMS/cdms-commons – ListSearchParameter, QueryResponse
  • Probe against cdms-integrationtest (preset), 2026-09-21
Search