moving DBDirectClient to instance.* b/c it only make sense there and cleans linking

This commit is contained in:
Eliot Horowitz
2009-01-02 16:41:13 -05:00
parent 7dde088721
commit ce95083dc2
5 changed files with 49 additions and 42 deletions

View File

@@ -505,3 +505,34 @@ void dbexit(int rc, const char *why) {
log() << " dbexit: really exiting now" << endl;
exit(rc);
}
auto_ptr<DBClientCursor> DBDirectClient::query(const char *ns, BSONObj query, int nToReturn , int nToSkip ,
BSONObj *fieldsToReturn , int queryOptions ){
auto_ptr<DBClientCursor> c( new DBClientCursor( new DirectConnector() , ns ,
query , nToReturn , nToSkip , fieldsToReturn , queryOptions ));
if ( c->init() )
return c;
return auto_ptr< DBClientCursor >( 0 );
}
BSONObj DBDirectClient::findOne(const char *ns, BSONObj query, BSONObj *fieldsToReturn , int queryOptions ){
auto_ptr<DBClientCursor> c =
this->query(ns, query, 1, 0, fieldsToReturn, queryOptions);
if ( ! c->more() )
return BSONObj();
return c->next().copy();
}
bool DirectConnector::send( Message &toSend, Message &response, bool assertOk ){
DbResponse dbResponse;
assembleResponse( toSend, dbResponse );
assert( dbResponse.response );
response = *dbResponse.response;
return true;
}