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

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Won't Fix
    • 2.3.0
    • None
    • Internal Client
    • Windows 7 64 SP1
      MongoDB 2.2.0
      MS VS 2010
      C++ driver
    • Fully Compatible
    • 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

            andrew.morrow@mongodb.com Andrew Morrow
            therefore George Thompson
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: