Esempio n. 1
0
    bool DBClientWithCommands::exists( const string& ns ) {
        list<string> names;

        string db = nsGetDB( ns ) + ".system.namespaces";
        BSONObj q = BSON( "name" << ns );
        return count( db.c_str() , q, QueryOption_SlaveOk ) != 0;
    }
Esempio n. 2
0
    bool DBClientCursor::initCommand(){
        BSONObj res;

        bool ok = _client->runCommand( nsGetDB( ns ), query, res, opts );
        replyToQuery( 0, *batch.m, res );
        dataReceived();

        return ok;
    }
Esempio n. 3
0
 BSONObj DBClientWithCommands::mapreduce(const string &ns, const string &jsmapf, const string &jsreducef, BSONObj query, MROutput output) {
     BSONObjBuilder b;
     b.append("mapreduce", nsGetCollection(ns));
     b.appendCode("map", jsmapf);
     b.appendCode("reduce", jsreducef);
     if( !query.isEmpty() )
         b.append("query", query);
     b.append("out", output.out);
     BSONObj info;
     runCommand(nsGetDB(ns), b.done(), info);
     return info;
 }