Retrieves the count of documents for a specified doctype based on the provided parameters.

This function performs an asynchronous request to the server to get the count of documents of the specified doctype. It supports parameters to apply filters, enable debugging, and specify whether the results should be returned as a dictionary.

// Retrieve the count of 'Employee' documents without any filters.
const params: GetCountParams = {
doctype: 'Employee',
};
const count = await getCount(params);
console.log(count); // Logs the count of Employee documents
// Get the count of 'Product' documents with a filter on 'status' being 'Active'.
const params: GetCountParams = {
doctype: 'Product',
filters: { status: 'Active' },
};
const count = await getCount(params);
console.log(count); // Logs the count of active products

Throws an error if the request fails or if there is an issue processing the parameters.

  • Parameters

    • params: GetCountParams

      The parameters to customize the query. This includes:

      • doctype: The document type for which the count is to be retrieved.
      • filters: Optional filter conditions to apply to the count query.
      • debug: Optional flag to enable debugging.
      • as_dict: Optional flag to specify the format of the results (default is true).
      • cache: Optional flag to enable or disable caching of the request.

    Returns Promise<any>

    A promise that resolves to the count of documents of the specified type.