On Wednesday, September 19, 2012 9:16:55 PM UTC-7, David Hows wrote:
> Hi Mick,
> The BSON function is actually a macro with a definition of
> #define BSON(x) (( mongo::BSONObjBuilder(64) << x ).obj())
> You can build an object by creating a BSONObjBuilder and then just start
> appending things too it, like so;
> BSONObjBuilder query2;
> query2.append("d", 1);
> query2.append("t", 2);
> query2.append("l", "mine");
> Finally, when you need to use it for a query just use the .obj() method.
> eg conn.query(ns, query2.obj());
> Hope that helps,
> David
> On Thursday, September 20, 2012 7:31:33 AM UTC+10, Mick wrote:
>> In C++ , instead of doing this:
>> qryStr = QUERY("d" << 1 << "t" << 2 << "l" << "mine");
>> bsonStr = BSON("d" << 1 << "t" << 2 << "l" << "mine");
>> can I do something like
>> strStream << "d" << 1 << "t" << 2 << "l" << "mine";
>> qryStr = QUERY(strStream);
>> bsonStr = BSON(strStream);
>> I tried defining strStream as stringstream, but it's complaining.
>> Is that even possible in C++?
>> Thank you in advance.