Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7716

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

    XMLWordPrintable

    Details

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

      Description

      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).

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: