---
title: "Count Query Results"
url: "https://docs.ravendb.net/6.2/client-api/session/querying/how-to-count-query-results"
version: "6.2"
language: "nodejs"
---

# Count Query Results

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-count-query-results.md), [Python](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-count-query-results.python.md), [PHP](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-count-query-results.php.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - The following options are available to **count query results**:
>
>   - [Count](#count)
>
>   - [Get number of results from query stats](#get-count-from-query-stats)

## Count

- Call `count` to get the number of items in the query results.

- Method `longCount`, which is also available, produces exactly the same results as `count`.  
  It is only included to be consistent with the .NET client.

> **Note**
>
> ### Query
>
> ```javascript
> const numberOfOrders = await session
>   .query({ collection: "Orders" })
>   .whereEquals("ShipTo.Country", "UK")
>    // Call 'count' to get the number of results
>   .count();
>
> // The query returns the NUMBER of orders shipped to UK
> ```
>
> ### RQL
>
> ```sql
> from "Orders"
> where ShipTo.Country == "UK" limit 0, 0
>
> // The RQL generated will trigger query execution
> // however, no documents are returned (limit is set 0)
> ```

## Get count from query stats

- When executing a query, you can retrieve the query statistics, which include the total number of results.

- The total number of results is available in the `totalResults` property of the `QueryStatistics` object.  
  Learn more in [Get Query Statistics](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-get-query-statistics.nodejs.md).

## See also

- [Query overview](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-query.nodejs.md)
- [What is a Document Query](https://docs.ravendb.net/6.2/client-api/session/querying/document-query/what-is-document-query.nodejs.md)
- [Filter by Field Presence](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-filter-by-field.nodejs.md)
- [Get Query Statistics](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-get-query-statistics.nodejs.md)
- [Filtering](https://docs.ravendb.net/6.2/indexes/querying/filtering.nodejs.md)
- [RQL - Raven Query Language](https://docs.ravendb.net/6.2/client-api/session/querying/what-is-rql.md)
