Fetch Unique Keys from a Document

Fetch the Unique Values of a Field/Key in a Collection (Sortable) in WorqDB. This is useful when you want to fetch all the unique values of a field/key in a collection.

curl --location 'https://api.worqhat.com/api/collections/data/fetch/unique' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
  "collection": "Sample collection",
  "key": "Sample Key",
}'

This will return all the unique values of the key in the collection.

Sort the Unique Values by a Key

You can also sort the unique values by a key. This is useful when you want to fetch all the unique values of a field/key in a collection and sort them by another field/key.

curl --location 'https://api.worqhat.com/api/collections/data/fetch/unique' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
  "collection": "Sample collection",
  "key": "Sample Key",
  "orderBy": "Sample Data",
  "orderType": "asc"
}'

This will return all the unique values of the key in the collection sorted by the Sample Data key in ascending order.

Try it out in the API Reference

View API Reference to Implement

Visit the API Reference to learn how to fetch Unique Values of a Key in your projects. Get access to Sample Code, API Endpoints and run it right within the browser to test it out.