Skip to content

Instantly share code, notes, and snippets.

@choplin
Created October 4, 2011 10:54
Show Gist options
  • Save choplin/1261347 to your computer and use it in GitHub Desktop.
Save choplin/1261347 to your computer and use it in GitHub Desktop.
how to use _addSpecial command via c++ driver
BSONObjBuilder b;
b.append( "query", BSONObj() ); // append original BSON object of query
b.append( "$maxScan", 1 ); // append special parameter
auto_ptr<DBClientCursor> cursor = c.query( ns, Query(b.obj()) );
while( cursor->more() ){
BSONObj p = cursor->next();
cout << p.toString() << endl;
}
@choplin
Copy link
Author

choplin commented Oct 4, 2011

forget to add

DBClientConnection c;
c.connect("localhost");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment