distinct( )


Returns the distinct values that match the query, without duplicates.

The distinct() function returns a Promise that resolves to:

  • The distinct values found in the specified field when running the query.
  • Additional information about the results, such as the number of values that match the query.

Unlike find(), which returns all item objects that match the query, distinct() returns matching field values, and eliminates duplicate field values from the query result. You cannot use find() and distinct() together.

For an item to be resolved as distinct, only the specified field must be distinct. Other fields for that item in the collection are not evaluated when resolving the promise.

The Promise is rejected if distinct() is called with incorrect permissions or if any of the functions used to refine the query is invalid.

Note: Only site visitors with Data Read permissions can retrieve and view data. You can override the permissions by setting the suppressAuth option to true.

Method Declaration
Copy
Method Parameters
propertyNamestringRequired

The property whose value will be compared for distinct values.


optionsWixDataQueryOptions

An object containing options to use when processing this operation.

Returns
Return Type:Promise<WixDataQueryResult>
Was this helpful?
Yes
No