Currently, mongocxx::collection::distinct returns a mongocxx::cursor that provides a single document, the database reply document for the 'distinct' command. This is not in the spirit of the CRUD spec, which requires an iterator over the distinct values.
Possible options:
- Return a bsoncxx::array::value with the distinct keys as elements
- Return a (synthesized) mongocxx::cursor over documents like this:
// for keys a .. z { "key": "a" } { "key": "b" } ... { "key": "z" }
Ideally, SERVER-3141 would get spec'd with a document format that we could emulate until it's implemented server-side as a command cursor.
- is related to
-
CXX-1406 Provide example and docs for using collection::distinct
- Closed
- related to
-
SERVER-3141 distinct needs to have a way to output to a cursor for large result sets
- Closed