本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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());
}
}