Count the number of documents in a collection that match a specified query. This endpoint is useful for pagination, analytics, and understanding the size of your dataset.

post/store/count

Request

  • Base URL: https://YOUR_CLOUD_URL_ENDPOINT/api/v4
  • URL: https://YOUR_CLOUD_URL_ENDPOINT/api/v4/store/count
  • Auth: HTTP bearer

Headers

X-DITTO-TXN-IDinteger

Optional transaction ID header that ensures consistency. If specified, the operation will only proceed if the Big Peer's transaction ID is equal to or greater than this value. This prevents reading stale data by ensuring you're operating on a sufficiently up-to-date version of the database.

Request body

argsunknown
collectionstring required

The name of the collection to count documents in

querystring required

A query expression that filters which documents to count. Use parameterized values with :param syntax for better security and performance

Example request

{
  "collection": "people",
  "query": "favoriteBook.title == 'The Great Gatsby'"
}

Response

The count operation completed successfully. Returns the total number of matching documents and the transaction ID of the operation.

countinteger required

The total number of documents that matched the query criteria

txnIdinteger required

The transaction ID at which this count was performed, useful for consistency checks

Example response

{
  "count": 100,
  "txnId": 9000
}

Changes

No recorded changes to this operation across all 1 revision of this API.