Skip to main content

Distinct

Distinct Field Values

This entrypoint finds the distinct values for a specified field across a target collection and returns the results in an array.

  • GET /{base_url}/distinct/:field

Parameters

NameTypeInDescription
fieldstringparamThe field for which to return distinct values

Example

request

curl \
-X GET \
-H "Accept: application/json" \
https://example.com/users/distinct/name

response

Status: 200
["Andrew", "Andrew-2nd", "Mike"]

Distinct Field Values - Advanced

This entrypoint finds the distinct values for a specified field across a target collection and returns the results in an array.

  • POST /{base_url}/distinct/:field

Parameters

NameTypeInDescription
fieldstringparamThe field for which to return distinct values
filterstringbodyMongose Filter that specifies the match rules to retrieve the distinct values

Example

request

curl \
-X POST \
-H "Accept: application/json" \
https://example.com/users/distinct/name \
-d '{
"filter": {
"name": { "$regex": "drew", "$options": "i" }
}
}'

response

Status: 200
["Andrew", "Andrew-2nd"]