当前位置: 首页>>代码示例>>C++>>正文


C++ NamespaceDetails::findOne方法代码示例

本文整理汇总了C++中NamespaceDetails::findOne方法的典型用法代码示例。如果您正苦于以下问题:C++ NamespaceDetails::findOne方法的具体用法?C++ NamespaceDetails::findOne怎么用?C++ NamespaceDetails::findOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NamespaceDetails的用法示例。


在下文中一共展示了NamespaceDetails::findOne方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: haveAdminUsers

 bool RestAdminAccess::haveAdminUsers() const {
     Client::Transaction txn(DB_TXN_READ_ONLY | DB_TXN_SNAPSHOT);
     openAdminDb();
     readlocktry rl(/*"admin.system.users", */10000);
     uassert( 16173 , "couldn't get read lock to get admin auth credentials" , rl.got() );
     Client::Context cx( "admin.system.users", dbpath, false );
     BSONObj o;
     NamespaceDetails *d = nsdetails( "admin.system.users" );
     bool ok = d != NULL && d->findOne(BSONObj(), o);
     txn.commit();
     return ok;
 }
开发者ID:lucciano,项目名称:mongo-1,代码行数:12,代码来源:restapi.cpp

示例2: gtidExistsInOplog

 bool gtidExistsInOplog(GTID gtid) {
     Client::ReadContext ctx(rsoplog);
     // TODO: Should this be using rsOplogDetails, verifying non-null?
     NamespaceDetails *d = nsdetails(rsoplog);
     BSONObjBuilder q;
     BSONObj result;
     addGTIDToBSON("_id", gtid, q);
     const bool found = d != NULL &&
         d->findOne(
            q.done(),
            result
            );
     return found;
 }
开发者ID:aberg001,项目名称:mongo,代码行数:14,代码来源:oplog.cpp

示例3: getAdminUser

 BSONObj RestAdminAccess::getAdminUser( const string& username ) const {
     Client::Transaction txn(DB_TXN_READ_ONLY | DB_TXN_SNAPSHOT);
     openAdminDb();
     Client::GodScope gs;
     readlocktry rl(/*"admin.system.users", */10000);
     uassert( 16174 , "couldn't get read lock to check admin user" , rl.got() );
     Client::Context cx( "admin.system.users" );
     BSONObj user;
     NamespaceDetails *d = nsdetails( "admin.system.users" );
     if ( d != NULL && d->findOne( BSON( "user" << username ) , user ) ) {
         txn.commit();
         return user.copy();
     }
     return BSONObj();
 }
开发者ID:lucciano,项目名称:mongo-1,代码行数:15,代码来源:restapi.cpp

示例4: applyRefOp

 // find all oplog entries for a given OID in the oplog.refs collection and apply them
 // TODO this should be a range query on oplog.refs where _id.oid == oid and applyOps to
 // each entry found.  The locking of the query interleaved with the locking in the applyOps
 // did not work, so it a sequence of point queries.  
 // TODO verify that the query plan is a indexed lookup.
 // TODO verify that the query plan does not fetch too many docs and then only process one of them.
 void applyRefOp(BSONObj entry) {
     OID oid = entry["ref"].OID();
     LOG(3) << "apply ref " << entry << " oid " << oid << endl;
     long long seq = 0; // note that 0 is smaller than any of the seq numbers
     while (1) {
         BSONObj entry;
         {
             Client::ReadContext ctx(rsOplogRefs);
             // TODO: Should this be using rsOplogRefsDetails, verifying non-null?
             NamespaceDetails *d = nsdetails(rsOplogRefs);
             if (d == NULL || !d->findOne(BSON("_id" << BSON("$gt" << BSON("oid" << oid << "seq" << seq))), entry, true)) {
                 break;
             }
         }
         BSONElement e = entry.getFieldDotted("_id.seq");
         seq = e.Long();
         BSONElement eOID = entry.getFieldDotted("_id.oid");
         if (oid != eOID.OID()) {
             break;
         }
         LOG(3) << "apply " << entry << " seq=" << seq << endl;
         applyOps(entry["ops"].Array());
     }
 }
开发者ID:aberg001,项目名称:mongo,代码行数:30,代码来源:oplog.cpp


注:本文中的NamespaceDetails::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。