[CDRIVER-1201] Examples for common tasks with no helper functions Created: 14/Apr/16  Updated: 19/Oct/16  Resolved: 17/Jun/16

Status: Closed
Project: C Driver
Component/s: docs, libmongoc
Affects Version/s: None
Fix Version/s: 1.4.0

Type: New Feature Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Ian Boros
Resolution: Done Votes: 0
Labels: intern2016
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-1200 Documentation error for "explain" Closed

 Description   

The C Driver is lower-level than most, and doesn't provide helper functions for some common tasks like "explain" and "distinct". Make a list of common tasks and make a new page in the documentation with a copy-and-pastable example for each. Move some existing examples like the "explain" command example at the bottom of mongoc_collection_find.page to this new page.



 Comments   
Comment by Githook User [ 27/Jun/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@emptysquare.net'}

Message: Merge pull request #342 from puppyofkosh/CDRIVER-1201-fix-man

CDRIVER-1201 fix man
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/da098a6fc30ef670e935a4465758417068733dbc

Comment by Githook User [ 27/Jun/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@emptysquare.net'}

Message: Merge pull request #342 from puppyofkosh/CDRIVER-1201-fix-man

CDRIVER-1201 fix man
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/da098a6fc30ef670e935a4465758417068733dbc

Comment by Githook User [ 17/Jun/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1201 common-operations doc layout
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/b6c9403335656dccc66051faf43bc80e9d633f4d

Comment by Githook User [ 17/Jun/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@emptysquare.net'}

Message: Merge pull request #337 from puppyofkosh/CDRIVER-1201

CDRIVER-1201 added documentation for common operations
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/943de1b9bfae62ab2c8485f57c29a09c268d191e

Comment by Githook User [ 17/Jun/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@emptysquare.net'}

Message: Merge pull request #337 from puppyofkosh/CDRIVER-1201

CDRIVER-1201 added documentation for common operations
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/943de1b9bfae62ab2c8485f57c29a09c268d191e

Comment by Githook User [ 17/Jun/16 ]

Author:

{u'name': u'ian boros', u'email': u'ian.boros@10gen.com'}

Message: CDRIVER-1201 added documentation for common operations
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/5c17557e9146058aa4c3d83d315da41eb4bac5fb

Comment by Bernie Hackett [ 14/Jun/16 ]

Lets not provide examples for group. See SERVER-14193.

Comment by A. Jesse Jiryu Davis [ 14/Jun/16 ]

Yes, perfect. For all these commands you can do db = mongoc_client_get_database, then mongoc_database_command_simple (db, ...).

copydb's distinctive among these because it must be run on the database called "admin". Since it's always run on the same database, it might be more natural to demonstrate it with mongoc_client_command_simple (client, "admin", ...).

https://docs.mongodb.com/manual/reference/command/copydb/

For "distinct" and "group", you can include instructions for setting read preferences.

We can talk over how to instruct users to run "mapreduce". By default mapreduce creates a collection that you must query to get the results. This has to be done on the primary, since only the primary is allowed to create a collection. You can also do an "inline" mapreduce that returns the results directly. This can be run on a secondary since it only stores the results temporarily in server memory, not disk.

Comment by Ian Boros [ 14/Jun/16 ]

For all of these examples, can I just use the mongoc_database_command_simple function to invoke the command on the server? That seems to work for all of them, but I'm not sure if there's a more idiomatic way.

Comment by A. Jesse Jiryu Davis [ 13/Jun/16 ]

Let's do:

  • explain
  • distinct
  • mapreduce
  • group
  • copydb
  • cloneCollection

For mapreduce and group, port the examples from the Python driver: https://api.mongodb.com/python/current/examples/aggregation.html

copydb: https://api.mongodb.com/python/current/examples/copydb.html

Test against MongoDB 3.2.

You can use the MongoDB Manual for command syntax, e.g. for cloneCollection:

https://docs.mongodb.com/manual/reference/command/cloneCollection/#dbcmd.cloneCollection

Test out the command syntax in the mongo shell first, then write a C example and include it in an "examples" doc.

Consider how best to organize these examples so users can find them and they don't collect into one huge page.

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