Count Query Results


  • 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.

const numberOfOrders = await session
    .query({ collection: "Orders" })
    .whereEquals("ShipTo.Country", "UK")
     // Call 'count' to get the number of results

// The query returns the NUMBER of orders shipped to UK
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 number of results is available in the QueryStatistics object as:

    • totalResults
    • longTotalResults
  • Learn more in Get Query Statistics.