Thanks David, that will do.
I'm working my way through an understanding of when and how to use the Query object. According to "MongoDB in Action": "Unique to C++ is the requirement that you explicitly mark BSON documents that will be used as query selectors." I took that to mean that you
must use a Query object (the said explicitly marked BSON document) as a query selector. But I can skip the Query() constructor, use BSON and set it to a BSONObj, e.g
BSONObj querySelector = BSON("attrs.pingtime" << LTE << 20); printQuery(c, datacollection, querySelector);The printQuery function's 3rd parameter is a Query object but it accepts the BSONObj selector which now makes sense.
Or I can skip the Query() constructor, use BSON, and set it to a Query object.
Query querySelector = BSON( "attrs.pingtime" << LTE << 20 );
And they both work as well as:
Query querySelector = Query( BSON("attrs.pingtime" << LTE << 20) ) ;or using the macro:
Query querySelector = QUERY( "attrs.pingtime" << LTE << 20 );
A very naive question: Couldn't the helper methods of the Query class have been implemented in BSONObj? Or, conversely, why couldn't a server-side count method be implemented with Query?
Thanks,
Mark