Skip to content
This page View Markdown Open in ChatGPT Open in Claude

getTotalCount

getTotalCount=true adds totalCount to the answer : the number of rows matching the filter, before skip and limit. One call gives the page and the total.

Query param
GET /api/schema/admin/mysql8/inventory/customers?find={isActive:1}&skip=0&limit=2&getTotalCount=true
Body of the query APIs
{ "find": { "isActive": 1 }, "skip": 0, "limit": 2, "getTotalCount": true }
Answer
{
    "success": true,
    "statusCode": 200,
    "data": [
        { "customer_id": 1, "first_name": "Bob", "last_name": "Lin" },
        { "customer_id": 2, "first_name": "Alice", "last_name": "Page" }
    ],
    "totalCount": 5
}
  • false or absent : no totalCount and no count query.
  • It works on get all, get all by stream, query and query by stream. The count API gives the number alone.
  • totalCount also appears in the answer of a stream, after the rows.
  • The count runs as a second query on the database ; on a very big table with a complex filter it costs as much as the query itself.