Counts the number of items in a data collection that match the provided filtering preferences.
You can only call this method when authenticated as a Wix app or Wix user identity.
ID of the collection for which to count query results.
Filter object in the following format:
"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }
.
Examples of operators: $eq
, $ne
, $lt
, $lte
, $gt
, $gte
, $in
, $hasSome
, $hasAll
, $startsWith
, $contains
.
Note: The values you provide for each field must adhere to that field's type. For example, when filtering by a field whose type is Date and Time, use an object in the following format: "someDateAndTimeFieldKey": { "$date": "YYYY-MM-DDTHH:mm:ss.sssZ"}
. Learn more about data types in Wix Data.
Whether to retrieve data from the primary database instance. This decreases performance but ensures data retrieved is up to date even immediately after an update. Learn more about Wix Data and eventual consistency.
Default: false
Language to translate result text into, in IETF BCP 47 language tag format. If provided, the result text is returned in the specified language. Note: Translation for the specified language must be enabled for the collection in Wix Multilingual.
If not provided, result text is not translated.
Additional parameters specific to the Wix app collection you are querying.
When querying the Wix Stores Products collection, pass the following optional parameters:
includeHiddenProducts
: Whether to include hidden products in the response. Default: false
.includeVariants
: Whether to include product variants in the query. Default: false
.Options for the Publish plugin. This plugin allows items in a data collection to be marked as draft or published. Published items are visible to site visitors, while draft items are not.
Number of items matching the query.
curl -X POST \
'https://www.wixapis.com/wix-data/v2/items/count' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-d '{
"dataCollectionId": "cities",
"filter": {
"state": "California"
}
}'
{
"totalCount": 4
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.