[CXX-295] Allow count to work with query hints Created: 04/Aug/14  Updated: 23/Oct/14  Resolved: 12/Sep/14

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: legacy-1.0.0-rc1

Type: Improvement Priority: Major - P3
Reporter: Barrie Segal Assignee: Tyler Brock
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends

 Comments   
Comment by Githook User [ 12/Sep/14 ]

Author:

{u'username': u'TylerBrock', u'name': u'Tyler Brock', u'email': u'tyler.brock@gmail.com'}

Message: CXX-295 include all query modifiers in count command
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/3870f932eac501fb2b7e53a42a9c79c697817a80

Comment by Githook User [ 12/Sep/14 ]

Author:

{u'username': u'TylerBrock', u'name': u'Tyler Brock', u'email': u'tyler.brock@gmail.com'}

Message: CXX-295 Allow count to work with query hints
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/921a4c6d469b9c0a60f6e88432dfb219a83d7961

Comment by Tyler Brock [ 12/Sep/14 ]

Drew, it seems we can take advantage of the fact that Query::hint() had a useless overload that took a string. What I did was repurpose that method to take an index name as opposed to a json string representation of the index spec. This way we can use Query to hold a hint that can either be either an index spec (BSONObj) or index name (std::string).

This is good because:

  • When the query gets unpacked in the _countCmd method we can use either to support current and future server versions.
  • The api isn't terrible because we avoid adding another parameter to the count method.
  • It fits well with our current design.
Comment by Tyler Brock [ 11/Sep/14 ]

https://github.com/mongodb/mongo-cxx-driver/pull/155

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