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


C++ MojDb::delKind方法代码示例

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


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

示例1: testKindPermissions

MojErr MojDbPermissionTest::testKindPermissions(MojDb& db)
{
	MojObject kind;
	MojErr err = kind.fromJson(MojTestKind1);
	MojTestErrCheck(err);

	// new kind, mismatched owner and caller
	MojDbReq req(false);
	err = req.domain(_T("com.bar"));
	MojTestErrCheck(err);
	err = db.putKind(kind, MojDb::FlagNone, req);
	MojTestErrExpected(err, MojErrDbPermissionDenied);
	// new kind, matched owner and caller
	err = req.domain(_T("com.foo"));
	MojTestErrCheck(err);
	err = db.putKind(kind, MojDb::FlagNone, req);
	MojTestErrCheck(err);
	// existing kind, matched owner and caller
	err = db.putKind(kind, MojDb::FlagNone, req);
	MojTestErrCheck(err);
	// existing kind, mismatched owner and caller
	err = req.domain(_T("com.bar"));
	MojTestErrCheck(err);
	err = db.putKind(kind, MojDb::FlagNone, req);
	MojTestErrExpected(err, MojErrDbPermissionDenied);
	// delKind, mismatched owner and caller
	MojString id;
	err = id.assign(_T("PermissionTest:1"));
	MojTestErrCheck(err);
	bool found = false;
	err = db.delKind(id, found, MojDb::FlagNone, req);
	MojTestErrExpected(err, MojErrDbPermissionDenied);

	return MojErrNone;
}
开发者ID:KyleMaas,项目名称:db8,代码行数:35,代码来源:MojDbPermissionTest.cpp

示例2: testEnforce

MojErr MojDbQuotaTest::testEnforce(MojDb& db)
{
	// set quota size to current usage
	MojInt64 quotaUsage1 = 0;
	MojErr err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage1);
	MojTestErrCheck(err);
	MojObject obj;
	err = obj.putString(_T("owner"), _T("com.foo.bar"));
	MojErrCheck(err);
	err = obj.putInt(_T("size"), quotaUsage1);
	MojErrCheck(err);
	err = db.putQuotas(&obj, &obj + 1);
	MojErrCheck(err);
	err = put(db, MojTestKind1Objects[3]);
	MojTestErrExpected(err, MojErrDbQuotaExceeded);
	// Try to delete the kind
	MojString kindStr;
	err = kindStr.assign(_T("Test:1"));
	MojTestErrCheck(err);
	bool found = false;
	err = db.delKind(kindStr, found);

    //The delete should be failure, because it contain sub kind "Test2:1"
    MojTestErrExpected(err,MojErrDbKindHasSubKinds); 
    MojTestAssert(!found); 

	return MojErrNone;
}
开发者ID:rogerjstringer,项目名称:db8,代码行数:28,代码来源:MojDbQuotaTest.cpp

示例3: testEnforce

MojErr MojDbQuotaTest::testEnforce(MojDb& db)
{
	// set quota size to current usage
	MojInt64 quotaUsage1 = 0;
	MojErr err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage1);
	MojTestErrCheck(err);
	MojObject obj;
	err = obj.putString(_T("owner"), _T("com.foo.bar"));
	MojErrCheck(err);
	err = obj.putInt(_T("size"), quotaUsage1);
	MojErrCheck(err);
	err = db.putQuotas(&obj, &obj + 1);
	MojErrCheck(err);
	err = put(db, MojTestKind1Objects[3]);
	MojTestErrExpected(err, MojErrDbQuotaExceeded);
	// make sure we can delete the kind
	MojString kindStr;
	err = kindStr.assign(_T("Test:1"));
	MojTestErrCheck(err);
	bool found = false;
	err = db.delKind(kindStr, found);
	MojTestErrCheck(err);
	MojTestAssert(found);

	return MojErrNone;
}
开发者ID:anttiharju-owo,项目名称:db8,代码行数:26,代码来源:MojDbQuotaTest.cpp

示例4: delKindTest

MojErr MojDbPurgeTest::delKindTest(MojDb& db)
{

	// start from scratch - purge everything
	MojUInt32 count = 0;
	MojErr err = db.purge(count, 0);
	MojTestErrCheck(err);
	MojTestAssert(count > 0);

	// purge again, make sure nothing is left
	err = db.purge(count, 0);
	MojTestErrCheck(err);
	MojTestAssert(count == 0);

	// make sure at least 2 objects exist
	MojDbQuery q;
	err = q.from(_T("PurgeTest:1"));
	MojTestErrCheck(err);
	MojDbCursor cursor;
	err = db.find(q, cursor);
	MojTestErrCheck(err);

	MojUInt32 objCount;
	err = cursor.count(objCount);
	MojTestErrCheck(err);
	err = cursor.close();
	MojTestErrCheck(err);

	if (objCount <= 1) {
		for (int i = objCount; i < 2; i++) {
			MojObject obj;
			err = obj.fromJson(MojTestObjStr1);
			MojTestErrCheck(err);
			err = db.put(obj);
			MojTestErrCheck(err);
			objCount++;
		}
	}

	// delete half the objects
	q.limit(objCount / 2);

	MojUInt32 delCount;
	err = db.del(q, delCount);
	MojTestErrCheck(err);

	// delete the kind
	MojString idStr;
	err = idStr.assign(_T("PurgeTest:1"));
	MojTestErrCheck(err);
	MojObject id(idStr);
	bool found;
	err = db.delKind(id, found);
	MojTestErrCheck(err);
	MojTestAssert(found);

	/*MojUInt32 deletedObjCount;
	err = q.where(_T("_del"), MojDbQuery::OpEq, true);
	MojTestErrCheck(err);
	q.includeDeleted(true);
	err = db.find(q, cursor);
	MojTestErrCheck(err);
	err = cursor.count(deletedObjCount);
	MojTestErrCheck(err);
	err = cursor.close();
	MojTestErrCheck(err);

	// now all the objects should be deleted
	MojTestAssert(deletedObjCount == objCount);*/

	// purge now
	err = db.purge(count, 0);
	MojTestErrCheck(err);

	return MojErrNone;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:76,代码来源:MojDbPurgeTest.cpp

示例5: testUsage


//.........这里部分代码省略.........
	MojTestErrCheck(err);
	MojTestAssert(quotaUsage1 > 0);
	// add prop to existing obj
	err = obj.fromJson(MojTestKind1Objects[0]);
	MojTestErrCheck(err);
	err = obj.put(_T("bar"), 2);
	MojTestErrCheck(err);
	err = db.put(obj, MojDb::FlagForce);
	MojTestErrCheck(err);
	MojInt64 kindUsage2 = 0;
	err = getKindUsage(db, _T("Test:1"), kindUsage2);
	MojTestErrCheck(err);
	MojTestAssert(kindUsage2 > kindUsage1);
	MojInt64 quotaUsage2 = 0;
	err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage2);
	MojTestErrCheck(err);
	MojTestAssert(quotaUsage2 > quotaUsage1);
	// add 2nd obj
	err = put(db, MojTestKind1Objects[1]);
	MojTestErrCheck(err);
	MojInt64 kindUsage3 = 0;
	err = getKindUsage(db, _T("Test:1"), kindUsage3);
	MojTestErrCheck(err);
	MojTestAssert(kindUsage3 > kindUsage2);
	MojInt64 quotaUsage3 = 0;
	err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage3);
	MojTestErrCheck(err);
	MojTestAssert(quotaUsage3 > quotaUsage2);
	// del first obj
	bool found = false;
	err = db.del(1, found, MojDb::FlagPurge);
	MojTestErrCheck(err);
	MojTestAssert(found);
	MojInt64 kindUsage4 = 0;
	err = getKindUsage(db, _T("Test:1"), kindUsage4);
	MojTestErrCheck(err);
	MojTestAssert(kindUsage4 == kindUsage3 - kindUsage2);
	MojInt64 quotaUsage4 = 0;
	err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage4);
	MojTestErrCheck(err);
	MojTestAssert(quotaUsage4 == quotaUsage3 - quotaUsage2);
	// add index
	err = obj.fromJson(MojTestKind1Str2);
	MojTestErrCheck(err);
	err = db.putKind(obj);
	MojTestErrCheck(err);
	MojInt64 kindUsage5 = 0;
	err = getKindUsage(db, _T("Test:1"), kindUsage5);
	MojTestErrCheck(err);
	MojTestAssert(kindUsage5 > kindUsage4);
	MojInt64 quotaUsage5 = 0;
	err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage5);
	MojTestErrCheck(err);
	MojTestAssert(quotaUsage5 > quotaUsage4);
	// update locale
	err = db.updateLocale(_T("FR_fr"));
	MojTestErrCheck(err);
	err = db.updateLocale(_T("EN_us"));
	MojTestErrCheck(err);
	MojInt64 kindUsage6 = 0;
	err = getKindUsage(db, _T("Test:1"), kindUsage6);
	MojTestErrCheck(err);
	MojTestAssert(kindUsage6 == kindUsage5);
	MojInt64 quotaUsage6 = 0;
	err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage6);
	MojTestErrCheck(err);
	MojTestAssert(quotaUsage6 == quotaUsage5);
	// drop index
	err = obj.fromJson(MojTestKind1Str1);
	MojTestErrCheck(err);
	err = db.putKind(obj);
	MojTestErrCheck(err);
	MojInt64 kindUsage7 = 0;
	err = getKindUsage(db, _T("Test:1"), kindUsage7);
	MojTestErrCheck(err);
	MojTestAssert(kindUsage7 == kindUsage4);
	MojInt64 quotaUsage7 = 0;
	err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage7);
	MojTestErrCheck(err);
	MojTestAssert(quotaUsage7 == quotaUsage4);
	// drop kind
	MojString kindStr;
	err = kindStr.assign(_T("Test:1"));
	MojTestErrCheck(err);
	err = db.delKind(kindStr, found);
	MojTestErrCheck(err);
	MojTestAssert(found);
	MojInt64 kindUsage8 = 0;
	err = getKindUsage(db, _T("Test:1"), kindUsage8);
	MojTestErrCheck(err);
	MojTestAssert(kindUsage8 == 0);
	MojInt64 quotaUsage8 = 0;
	err = getQuotaUsage(db, _T("com.foo.bar"), quotaUsage8);
	MojTestErrCheck(err);
	MojTestAssert(quotaUsage8 == 0);
	err = db.quotaStats(obj);
	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:rogerjstringer,项目名称:db8,代码行数:101,代码来源:MojDbQuotaTest.cpp


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