本文整理汇总了C++中UpdateIndexData::addPath方法的典型用法代码示例。如果您正苦于以下问题:C++ UpdateIndexData::addPath方法的具体用法?C++ UpdateIndexData::addPath怎么用?C++ UpdateIndexData::addPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UpdateIndexData
的用法示例。
在下文中一共展示了UpdateIndexData::addPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST( UpdateIndexDataTest, Simple2 ) {
UpdateIndexData a;
a.addPath( "ab" );
ASSERT_FALSE( a.mightBeIndexed( "a" ) );
a.clear();
ASSERT_FALSE( a.mightBeIndexed( "ab" ) );
}
示例2: doc
TEST_F(CurrentDateNodeTest, ApplyIndexesNotAffected) {
auto update = fromjson("{$currentDate: {a: true}}");
const CollatorInterface* collator = nullptr;
CurrentDateNode node;
ASSERT_OK(node.init(update["$currentDate"]["a"], collator));
Document doc(fromjson("{a: 0}"));
FieldRef pathToCreate("");
FieldRef pathTaken("a");
StringData matchedField;
auto fromReplication = true;
auto validateForStorage = true;
FieldRefSet immutablePaths;
UpdateIndexData indexData;
indexData.addPath("b");
Document logDoc;
LogBuilder logBuilder(logDoc.root());
auto indexesAffected = false;
auto noop = false;
node.apply(doc.root()["a"],
&pathToCreate,
&pathTaken,
matchedField,
fromReplication,
validateForStorage,
immutablePaths,
&indexData,
&logBuilder,
&indexesAffected,
&noop);
ASSERT_FALSE(noop);
ASSERT_FALSE(indexesAffected);
ASSERT_EQUALS(doc.root().countChildren(), 1U);
ASSERT_TRUE(doc.root()["a"].ok());
ASSERT_EQUALS(doc.root()["a"].getType(), BSONType::Date);
ASSERT_EQUALS(logDoc.root().countChildren(), 1U);
ASSERT_TRUE(logDoc.root()["$set"].ok());
ASSERT_EQUALS(logDoc.root()["$set"].countChildren(), 1U);
ASSERT_TRUE(logDoc.root()["$set"]["a"].ok());
ASSERT_EQUALS(logDoc.root()["$set"]["a"].getType(), BSONType::Date);
}
示例3: caseInsensitiveCollator
TEST(AddToSetNodeTest, ApplyRespectsCollationFromSetCollator) {
auto update = fromjson("{$addToSet: {a: {$each: ['abc', 'ABC', 'def', 'abc']}}}");
const CollatorInterface* binaryComparisonCollator = nullptr;
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], binaryComparisonCollator));
const CollatorInterfaceMock caseInsensitiveCollator(
CollatorInterfaceMock::MockType::kToLowerString);
node.setCollator(&caseInsensitiveCollator);
Document doc(fromjson("{a: []}"));
FieldRef pathToCreate("");
FieldRef pathTaken("a");
StringData matchedField;
auto fromReplication = true;
auto validateForStorage = true;
FieldRefSet immutablePaths;
UpdateIndexData indexData;
indexData.addPath("a");
Document logDoc;
LogBuilder logBuilder(logDoc.root());
auto indexesAffected = false;
auto noop = false;
node.apply(doc.root()["a"],
&pathToCreate,
&pathTaken,
matchedField,
fromReplication,
validateForStorage,
immutablePaths,
&indexData,
&logBuilder,
&indexesAffected,
&noop);
ASSERT_FALSE(noop);
ASSERT_TRUE(indexesAffected);
ASSERT_EQUALS(fromjson("{a: ['abc', 'def']}"), doc);
ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{$set: {a: ['abc', 'def']}}"), logDoc);
}
示例4: doc
TEST(AddToSetNodeTest, ApplyCreateEmptyArrayIsNotNoop) {
auto update = fromjson("{$addToSet: {a: {$each: []}}}");
const CollatorInterface* collator = nullptr;
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
Document doc(fromjson("{}"));
FieldRef pathToCreate("a");
FieldRef pathTaken("");
StringData matchedField;
auto fromReplication = true;
auto validateForStorage = true;
FieldRefSet immutablePaths;
UpdateIndexData indexData;
indexData.addPath("a");
Document logDoc;
LogBuilder logBuilder(logDoc.root());
auto indexesAffected = false;
auto noop = false;
node.apply(doc.root(),
&pathToCreate,
&pathTaken,
matchedField,
fromReplication,
validateForStorage,
immutablePaths,
&indexData,
&logBuilder,
&indexesAffected,
&noop);
ASSERT_FALSE(noop);
ASSERT_TRUE(indexesAffected);
ASSERT_EQUALS(fromjson("{a: []}"), doc);
ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{$set: {a: []}}"), logDoc);
}