Retrieves a list of distinct values for a given field in all items that match a query, without duplicates.
As with the Query Data Items method, this method retrieves items based on the filtering, sorting, and paging preferences you provide.
However, the Query Distinct Values method doesn't return all of the full items that match the query.
Rather, it returns all unique values of the field you specify in fieldName
for items that match the query.
If more than one item has the same value for that field, that value appears only once.
For more details on using queries, see API Query Language.
You can only call this method when authenticated as a Wix app or Wix user identity.
ID of the collection to query.
Item field name for which to return all distinct values.
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.
Sort order.
Whether to return the total count in the response for a query with offset paging.
When true
, the pagingMetadata
object in the response contains a total
field.
Default: false
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.
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.
Paging options to limit and skip the number of items.
Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not filter
or sort
.
List of distinct values contained in the field specified in fieldName
.
Paging information.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.