本文整理汇总了C++中MojDbReq::curKind方法的典型用法代码示例。如果您正苦于以下问题:C++ MojDbReq::curKind方法的具体用法?C++ MojDbReq::curKind怎么用?C++ MojDbReq::curKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojDbReq
的用法示例。
在下文中一共展示了MojDbReq::curKind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
MojErr MojDbKind::update(MojObject* newObj, const MojObject* oldObj, MojDbOp op, MojDbReq& req, bool checkSchema)
{
MojLogTrace(s_log);
MojErr err = checkPermission(op, req);
MojErrCheck(err);
err = req.curKind(this);
MojErrCheck(err);
#if defined(TESTDBKIND)
MojString s;
MojErr e2;
if (oldObj) {
e2 = oldObj->toJson(s);
MojLogInfo(s_log, _T("Kind_Update_OldObj: %s ;\n"), s.data());
}
if (newObj) {
e2 = newObj->toJson(s);
MojLogInfo(s_log, _T("Kind_Update_NewObj: %s ;\n"), s.data());
}
#endif
if (newObj) {
// add the _backup property if not set
if (m_backup && !newObj->contains(MojDb::SyncKey)) {
err = newObj->putBool(MojDb::SyncKey, true);
MojErrCheck(err);
}
// TEMPORARY!!! This should be done in pre-update to also check parent kinds
// warning message comes from preUpdate
if(checkSchema)
{
MojSchema::Result res;
err = m_schema.validate(*newObj, res);
MojErrCheck(err);
if (!res.valid())
{
MojErrThrowMsg(MojErrSchemaValidation, _T("schema validation failed for kind '%s': %s"),
m_id.data(), res.msg().data());
}
}
}
// update revSets and validate schema
err = preUpdate(newObj, oldObj, req);
MojErrCheck(err);
// update indexes
MojVector<MojDbKind*> kindVec;
MojInt32 idxcount = 0;
err = updateIndexes(newObj, oldObj, req, op, kindVec, idxcount);
MojLogInfo(s_log, _T("Kind_UpdateIndexes_End: %s; supers = %zu; indexcount = %zu; updated = %d \n"), this->id().data(),
m_supers.size(), m_indexes.size(), idxcount);
MojErrCheck(err);
return MojErrNone;
}
示例2: updateLocale
MojErr MojDbKind::updateLocale(const MojChar* locale, MojDbReq& req)
{
MojLogTrace(s_log);
MojAssert(locale);
MojErr err = req.curKind(this);
MojErrCheck(err);
for (IndexVec::ConstIterator i = m_indexes.begin(); i != m_indexes.end(); ++i) {
err = (*i)->updateLocale(locale, req);
MojErrCheck(err);
}
return MojErrNone;
}
示例3: drop
MojErr MojDbKind::drop(MojDbReq& req)
{
MojLogTrace(s_log);
MojErr err = checkPermission(OpKindUpdate, req);
MojErrCheck(err);
err = req.curKind(this);
MojErrCheck(err);
// drop indexes
MojErr errAcc = MojErrNone;
for (IndexVec::ConstIterator i = m_indexes.begin();
i != m_indexes.end(); ++i) {
errAcc = dropIndex(i->get(), req);
MojErrAccumulate(err, errAcc);
}
m_indexes.clear();
// remove self from super/sub kinds
errAcc = close();
MojErrAccumulate(err, errAcc);
return err;
}
示例4: configureIndexes
MojErr MojDbKind::configureIndexes(const MojObject& obj, const MojString& locale, MojDbReq& req)
{
MojLogTrace(s_log);
// make sure indexes changes count against our usage
MojErr err = req.curKind(this);
MojErrCheck(err);
// add default id index to set
MojObject idIndex;
err = idIndex.fromJson(IdIndexJson);
MojErrCheck(err);
ObjectSet newIndexObjects;
err = newIndexObjects.put(idIndex);
MojErrCheck(err);
// change back to a set and use contains
MojSet<MojString> indexNames;
MojString defaultIdxName;
err = defaultIdxName.assign(IdIndexName);
MojErrCheck(err);
err = indexNames.put(defaultIdxName);
MojErrCheck(err);
// add indexes to set to uniquify and order them
MojObject indexArray;
if (obj.get(IndexesKey, indexArray)) {
MojObject::ConstArrayIterator end = indexArray.arrayEnd();
for (MojObject::ConstArrayIterator i = indexArray.arrayBegin(); i != end; ++i) {
MojString indexName;
err = i->getRequired(MojDbIndex::NameKey, indexName);
MojErrCheck(err);
err = indexName.toLower();
MojErrCheck(err);
if (!indexNames.contains(indexName)) {
MojObject idx = *i;
// make sure we keep the lower-cased index name
err = idx.putString(MojDbIndex::NameKey, indexName);
MojErrCheck(err);
err = newIndexObjects.put(idx);
MojErrCheck(err);
err = indexNames.put(indexName);
MojErrCheck(err);
} else {
MojErrThrowMsg(MojErrDbInvalidIndexName, _T("db: cannot repeat index name: '%s'"), indexName.data());
}
}
}
// figure out what to add and what to delete
ObjectSet toDrop;
err = m_indexObjects.diff(newIndexObjects, toDrop);
MojErrCheck(err);
ObjectSet toAdd;
err = newIndexObjects.diff(m_indexObjects, toAdd);
MojErrCheck(err);
// drop deleted indexes
IndexVec newIndexes;
for (IndexVec::ConstIterator i = m_indexes.begin(); i != m_indexes.end(); ++i) {
if (toDrop.contains((*i)->object())) {
err = dropIndex(i->get(), req);
MojErrCheck(err);
} else {
err = newIndexes.push(*i);
MojErrCheck(err);
}
}
// add new indexes
for (ObjectSet::ConstIterator i = toAdd.begin(); i != toAdd.end(); ++i) {
// create index
MojRefCountedPtr<MojDbIndex> index(new MojDbIndex(this, m_kindEngine));
MojAllocCheck(index.get());
err = index->fromObject(*i, locale);
MojErrCheck(err);
// open index
err = openIndex(index.get(), req);
MojErrCheck(err);
err = newIndexes.push(index);
MojErrCheck(err);
}
// sort indexes by the prop vec so that for indexes that share prop prefixes, the shortest one comes first
err = newIndexes.sort();
MojErrCheck(err);
// update members
m_indexObjects = newIndexObjects;
m_indexes = newIndexes;
return MojErrNone;
}