[CDRIVER-329] add distinct helper to mongoc_collection_t Created: 30/Mar/14  Updated: 18/Oct/16  Resolved: 18/Oct/16

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: None
Fix Version/s: 1.5.0

Type: Improvement Priority: Major - P3
Reporter: Christian Hergert Assignee: Backlog - C Driver Team
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-1527 Add mongoc_client_[read|write|read_wr... Closed

 Description   

we need a helper for the distinct operation with mongoc_collection_t.



 Comments   
Comment by A. Jesse Jiryu Davis [ 18/Oct/16 ]

We're still doing this via CDRIVER-1527 instead.

Comment by A. Jesse Jiryu Davis [ 20/Sep/16 ]

These are good arguments for a helper function. My hope is that calling "distinct" via a new helper, "mongoc_client_command_with_opts" (CDRIVER-1527), will fulfill this requirement for drivers that wrap libmongoc. Same for any other command helper functions that you'd normally need separate functions for.

Note: we haven't signed on to the CRUD Spec. Complying more with the CRUD Spec is better than complying less with it, for sure, but we still make case-by-case decisions regarding its API.

Comment by J Rassi [ 20/Sep/16 ]

Re-opening for another round of consideration.

My argument for why this helper should exist:

  1. The CRUD spec mandates it.
  2. The C++ driver implements a distinct helper, and it would be convenient for the C++ distinct helper to not have to implement logic which is specific to server version, such as the requirement to raise an error if the user specifies a collation when connected to a deployment with a max wire version less than 5. It would be most natural for the C driver to provide a helper which implements this logic.

I'd suggest the following prototype:

mongoc_cursor_t *mongoc_collection_distinct(
	mongoc_collection_t *collection,
	const char *key,
	const bson_t *opts,
	const mongoc_read_prefs_t *read_prefs) BSON_GNUC_WARN_UNUSED_RESULT;

Comment by Hannes Magnusson [ 02/Sep/16 ]

No.. Lets not. Its not healthy to have command helpers for every thing in the world (besides, we only have helpers for maybe 1/4th of all commands)

Anyone who needs it should craft the command manually and use the run command interface instead

Generated at Wed Feb 07 21:09:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.