Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-267

Include regex elements in BSONArrayBuilder

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • legacy-1.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      The BSONArrayBuilder class in the MongoDB C++ driver API (http://api.mongodb.org/cplusplus/current/classmongo_1_1_b_s_o_n_array_builder.html) allows to build BSON arrays, eg.

      BSONArrayBuilder ba;
      ba.append("foo");
      ba.append("bar");
      ...
      connection->query("col", BSON("x" << BSON("$in" << ba.arr())));

      will do a query equal to the following at mongo shell:

      db.col.find({"x": {"$in": [ "foo", "bar" ] }})

      However, It seems that BSONArrayBuilder lacks a method to build a query based on regex instead of strings, in the following way (that works at mongo shell):

      db.col.find({"x": {"$in": [ /^foo/, /^bar/ ] }})

      This issue is about implementing the above functionality (or maybe I'm wrong...

      Note that Note that BSONObjBuilder class (http://api.mongodb.org/cplusplus/current/classmongo_1_1_b_s_o_n_obj_builder.html) has an appendRegex() method... I wonder why a similar method has not been included in the BSONArrayBuilder class.

            Assignee:
            tyler@10gen.com Tyler Brock
            Reporter:
            fgalan@gmail.com Fermín Galán Márquez
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: