Skip to content

Get total count

  • To get a total number of data objects in response we should pass the 'getTotalCount' value as a boolean.
  • If getTotalCount is true in the request, the response will get a total number of data objects.
  • By default its value is false.
  • The total number of data objects gets in the 'totalCount' key.

URL

  • Schema based API url

    /api/schema/user-path/instance/database/table?getTotalCount=true
    

  • schemaless API url

    /api/gen/user-path/instance/database/table?getTotalCount=true
    

Got a response with a number of record counts.

{
    "data": [
        {
            "customer_id": 1,
            "first_name": "Bob",
            "last_name": "Lin"
        },
        {
            "customer_id": 2,
            "first_name": "Alice",
            "last_name": "Page"
        }
    ],
    "totalCount": 2
}

getTotalCount in body

  • In the query for get data and query stream API we can provide 'getTotalCount' in body.
  • It will get response with the response data total count.

Request payload

{
    "find": {
        "first_name": "Wayne"
    },
    "getTotalCount": true
}

Response

{
    "success": true,
    "statusCode": 200,
    "data": [
        {
            "_id": "63e06907bd0e063920533baf",
            "customer_id": 82959,
            "first_name": "Wayne",
            "last_name": "Brown",
            "phone": 9683803357
        }
    ],
    "totalCount": 1
}