elixir-mongo / elixir-mongo/mongodb_ecto
Query distinct values of a field
- Dominant language
- Elixir
- Stars
- 378
- Forks
- 127
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to query the distinct values of a field in all the documents as in:
https://docs.mongodb.com/manual/reference/method/db.collection.distinct/
I tried to use the distinct function provided by Ecto (https://hexdocs.pm/ecto/Ecto.Query.html#distinct/3), but I have the following error:
```
** (Ecto.QueryError) MongoDB adapter does not support distinct clause in this query in query
```
Here is the code I try to run:
```
def list_tags do
query =
from(
a in Dataset,
distinct: :tags
)
query
|> Repo.all()
end
```
If the distinct function is not supported by the adapter, is there any other way to get the distinct values of a field?
Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.