change DBClientWithCommands count() to take a Query instead of a BSON object

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: Minor - P4
    • None
    • Affects Version/s: 2.3.0
    • Component/s: Internal Client
    • Environment:
      Windows 7 64 SP1
      MongoDB 2.2.0
      MS VS 2010
      C++ driver
    • Fully Compatible
    • Platforms 2017-01-23
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This member function:

      unsigned long long count (const string &ns, const BSONObj &query=BSONObj(), int options=0)

      of

      mongo::DBClientWithCommands

      only allows a BSONObj for query. Feature request: Allow complex Query objects (mongo::Query::isComplex == true).

      Work-arounds: Strip out complexity:

      query.obj["query"].embeddedObject()

      and use that as the parameter to count() when isComplex == true (useful in functions that accept complex Query objects). Or build an interim non-complex query, use that with count() and then add in sort, explain, etc.

      Arguably, this is unnecessary complexity. Allowing a Query object will be consistent with a member function that counts the "number of objects ... that match the query." You could change the parameter to &query=Query() as it should continue to accept BSONObj objects, so no compatibility issues (that I can thank of).

              Assignee:
              Andrew Morrow (Inactive)
              Reporter:
              George Thompson
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: