queryDistinctValues( )


Important:


Retrieves a list of distinct values for a given field for all items that match the query, without duplicates.

As with queryDataItems(), this function retrieves items based on the filtering, sorting, and paging preferences provided. However, this function does not return the full items that match the query. Rather, for items that match the query, it returns all unique values in the field specified in fieldName. If more than one item has the same value in that field, that value appears only once.

Method Declaration
Copy
function queryDistinctValues(
  payload: QueryDistinctValuesEnvelope,
): QueryDistinctValuesResponse | Promise<QueryDistinctValuesResponse>;
Method Parameters
payloadQueryDistinctValuesEnvelope
Returns
Return Type:QueryDistinctValuesResponse | Promise<QueryDistinctValuesResponse>
Example of `distinctValues` and `pagingMetadata` return values
JavaScript
import { externalDatabase } from "@wix/data/service-plugins"; externalDatabase.provideHandlers({ queryDistinctValues: async (payload) => { const { request, metadata } = payload; // Use the `request` and `metadata` received from Wix and // apply custom logic. return { // Return your response exactly as documented to integrate with Wix. // Return value example: distinctValues: ["US", "CA"], pagingMetadata: {}, }; }, });
Did this help?