[CXX-267] Include regex elements in BSONArrayBuilder Created: 01/Jul/14  Updated: 14/Aug/14  Resolved: 08/Jul/14

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

Type: New Feature Priority: Major - P3
Reporter: Fermín Galán Márquez 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
depends on CXX-278 Merge upstream changes for SERVER-14482 Closed

 Description   

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.



 Comments   
Comment by Andrew Morrow (Inactive) [ 01/Jul/14 ]

Hi fgalan@gmail.com -

I'm guessing this is just an oversight. You should feel free to send us a pull request with a fix, or we will try to get to it in the next release cycle for the legacy driver.

Thanks,
Andrew

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