本文整理汇总了C++中NamespaceDetails::createIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ NamespaceDetails::createIndex方法的具体用法?C++ NamespaceDetails::createIndex怎么用?C++ NamespaceDetails::createIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceDetails
的用法示例。
在下文中一共展示了NamespaceDetails::createIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_system_collection_insert
static int handle_system_collection_insert(const char *ns, const BSONObj &obj, bool logop) {
// Trying to insert into a system collection. Fancy side-effects go here:
// TODO: see insert_checkSys
if (mongoutils::str::endsWith(ns, ".system.indexes")) {
// obj is something like this:
// { _id: ObjectId('511d34f6d3080c48017a14d0'), ns: "test.leif", key: { a: -1.0 }, name: "a_-1", unique: true }
const string &coll = obj["ns"].String();
NamespaceDetails *details = getAndMaybeCreateNS(coll.c_str(), logop);
BSONObj key = obj["key"].Obj();
int i = details->findIndexByKeyPattern(key);
if (i >= 0) {
return ASSERT_ID_DUPKEY;
} else {
details->createIndex(obj);
}
} else if (legalClientSystemNS(ns, true)) {
if (mongoutils::str::endsWith(ns, ".system.users")) {
uassert( 14051 , "system.users entry needs 'user' field to be a string", obj["user"].type() == String );
uassert( 14052 , "system.users entry needs 'pwd' field to be a string", obj["pwd"].type() == String );
uassert( 14053 , "system.users entry needs 'user' field to be non-empty", obj["user"].String().size() );
uassert( 14054 , "system.users entry needs 'pwd' field to be non-empty", obj["pwd"].String().size() );
}
} else {
uasserted(16459, str::stream() << "attempt to insert in system namespace '" << ns << "'");
}
return 0;
}