[CDRIVER-2757] createIndexes guide is unclear Created: 19/Jul/18  Updated: 28/Oct/23  Resolved: 19/Jul/18

Status: Closed
Project: C Driver
Component/s: docs, libmongoc
Affects Version/s: 1.12.0
Fix Version/s: 1.13.0

Type: Improvement Priority: Major - P3
Reporter: Gustaf Neumann Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: api
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

all


Issue Links:
Duplicate

 Description   

is it possible to provide an additional public API function forĀ mongoc_collections to access the database, e.g. calledĀ  mongoc_collection_get_database()?

The need arose from trying to replace the deprecated function mongoc_collection_create_index() with the recommended interface based on mongoc_database_write_command_with_opts(), but this requires the db. The function has just the collection as input, so it would be appreciated to access the ->db member this way.



 Comments   
Comment by Githook User [ 19/Jul/18 ]

Author:

{'username': 'kevinAlbs', 'name': 'Kevin Albertson', 'email': 'kevin.albertson@10gen.com'}

Message: CDRIVER-2757 clarify create indexes doc
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/320f8341a7df94f2a90fea73c7a59c8824e1676d

Comment by Kevin Albertson [ 19/Jul/18 ]

Glad to help! That docs page is a bit misleading, and does indicate that mongoc_database_write_command_with_opts is the only way to create an index. We'll fix that.

Comment by Gustaf Neumann [ 19/Jul/18 ]

perfect! Thanks a lot. I have missed this API function! The issue is solved, sorry for the noise!

Comment by Kevin Albertson [ 19/Jul/18 ]

Hi gustafn, I think you can use mongoc_collection_write_command_with_opts. The only difference between mongoc_collection_write_command_with_opts and mongoc_database_write_command_with_opts is where the default read preference, read concern, and write concern of the command are inherited from.

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