Returns the distinct values that match the query, without duplicates.
The distinct()
function returns a Promise that resolves to:
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
.
The property whose value will be compared for distinct values.
An object containing options to use when processing this operation.