本文整理汇总了C++中MojDbQuery::toObject方法的典型用法代码示例。如果您正苦于以下问题:C++ MojDbQuery::toObject方法的具体用法?C++ MojDbQuery::toObject怎么用?C++ MojDbQuery::toObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojDbQuery
的用法示例。
在下文中一共展示了MojDbQuery::toObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MojErrCheck
MojErr MojDbSearchCache::QueryKey::setQuery(const MojDbQuery& query)
{
MojObject obj;
MojErr err = query.toObject(obj);
MojErrCheck(err);
bool foundOut=false;
obj.del(MojDbQuery::PageKey, foundOut);
obj.del(MojDbQuery::LimitKey, foundOut);
err = obj.toJson(m_query);
MojErrCheck(err);
setKind(query.from());
return err;
}
示例2: findAccountIdResult
/*
* Result of query for loginState entry with given username and serviceName when removing a buddy
*
* Remove buddy from buddyStatus and contact DB
*/
MojErr SendOneMessageHandler::findAccountIdResult(MojObject& result, MojErr findErr)
{
if (findErr) {
MojString error;
MojErrToString(findErr, error);
MojLogError(IMServiceApp::s_log, _T("findAccountIdResult failed: error %d - %s"), findErr, error.data());
// not much we can do here...
failMessage(ERROR_SEND_GENERIC_ERROR);
} else {
// parse out the accountId
readAccountIdFromResults(result);
if (!m_accountId.empty()){
// construct our where clause - find by username, accountId and servicename
MojDbQuery query;
query.where("username", MojDbQuery::OpEq, m_usernameTo);
query.where("accountId", MojDbQuery::OpEq, m_accountId);
query.from(IM_BUDDYSTATUS_KIND);
MojObject queryObject;
query.toObject(queryObject);
IMServiceHandler::logMojObjectJsonString(_T("findAccountIdResult - buddyStatus query: %s"), queryObject);
// call find
//virtual MojErr find(Signal::SlotRef handler, const MojDbQuery& query,
// bool watch = false, bool returnCount = false) = 0;
MojErr err = m_tempdbClient.find(this->m_findBuddySlot, query, /* watch */ false );
if (err) {
MojString error;
MojErrToString(err, error);
MojLogError(IMServiceApp::s_log, _T("findAccountIdResult dbClient.find() failed: error %d - %s"), err, error.data());
failMessage(ERROR_SEND_GENERIC_ERROR);
}
}
else {
MojLogError(IMServiceApp::s_log, _T("findAccountIdResult: no matching loginState record found for %s"), m_serviceName.data());
// tell the outgoing Command handler we are done
failMessage(ERROR_SEND_GENERIC_ERROR);
}
}
return MojErrNone;
}
示例3: createContactQuery
/*
* Create the query to find the buddy in contacts table by username and serviceName
*
* errors returned to caller
*/
MojErr SendOneCommandHandler::createContactQuery(MojDbQuery& query)
{
MojErr err = query.where("ims.value", MojDbQuery::OpEq, m_buddyName);
MojErrCheck(err);
err = query.where("ims.type", MojDbQuery::OpEq, m_serviceName);
MojErrCheck(err);
//add our kind to the object
err = query.from(IM_CONTACT_KIND);
MojErrCheck(err);
// log the query
MojObject queryObject;
err = query.toObject(queryObject);
MojErrCheck(err);
IMServiceHandler::logMojObjectJsonString(_T("createContactQuery: %s"), queryObject);
return MojErrNone;
}
示例4: updateObjsViaMerge
MojErr MojDbPerfUpdateTest::updateObjsViaMerge(MojDb& db, const MojChar* kindId, MojErr (MojDbPerfTest::*createFn) (MojObject&, MojUInt64))
{
// register all the kinds
MojTime time;
MojErr err = putKinds(db, time);
MojTestErrCheck(err);
// put objects using createFn
MojObject objs;
err = putObjs(db, kindId, numInsertForPut, createFn, objs);
MojTestErrCheck(err);
MojObject midObj;
bool found = objs.at(numInsertForPut/2, midObj);
MojTestAssert(found);
MojTime objTime;
err = mergeObj(db, midObj, objTime);
MojTestErrCheck(err);
MojUInt64 mergeTime = objTime.microsecs();
err = MojPrintF("\n -------------------- \n");
MojTestErrCheck(err);
err = MojPrintF(" merging single object - index %llu - of kind %s %llu times took: %llu microsecs\n", numInsertForPut/2, kindId, numMergeIterations, mergeTime);
MojTestErrCheck(err);
err = MojPrintF(" time per merge: %llu microsecs", (mergeTime) / (numMergeIterations));
MojTestErrCheck(err);
err = MojPrintF("\n\n");
MojTestErrCheck(err);
MojString buf;
err = buf.format("Merge single object - index %llu - %llu times,%s,%llu,%llu,%llu,\n", numInsertForPut/2, numMergeIterations, kindId, mergeTime, mergeTime/numMergeIterations, mergeTime/(1*numMergeIterations));
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
MojTime batchTime;
MojObject::ArrayIterator beginArr;
err = objs.arrayBegin(beginArr);
MojErrCheck(err);
err = batchMergeObj(db, beginArr, beginArr + (numInsertForPut / 10), batchTime);
MojTestErrCheck(err);
mergeTime = batchTime.microsecs();
err = MojPrintF(" merging batch - %llu objects - of kind %s %llu times took: %llu microsecs\n", numInsertForPut/10, kindId, numBatchMergeIterations, mergeTime);
MojTestErrCheck(err);
err = MojPrintF(" time per batch merge: %llu microsecs\n", (mergeTime) / (numBatchMergeIterations));
MojTestErrCheck(err);
err = MojPrintF(" time per object: %llu microsecs", (mergeTime) / (numInsertForPut/10 * numBatchMergeIterations));
MojTestErrCheck(err);
err = MojPrintF("\n\n");
MojTestErrCheck(err);
err = buf.format("Batch merge %llu objects %llu times,%s,%llu,%llu,%llu,\n", numInsertForPut/10, numBatchMergeIterations, kindId, mergeTime, mergeTime/numBatchMergeIterations, mergeTime/(numInsertForPut/10*numBatchMergeIterations));
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
MojTime mergeQueryTime;
MojTestErrCheck(err);
MojDbQuery query;
err = query.from(kindId);
MojTestErrCheck(err);
query.limit(numInsertForPut/5);
query.desc(true);
MojObject queryObj;
err = query.toObject(queryObj);
MojTestErrCheck(err);
MojString queryStr;
err = queryObj.stringValue(queryStr);
MojTestErrCheck(err);
MojObject props;
err = props.putString(_T("newKey"), _T("here's a new value"));
MojTestErrCheck(err);
MojUInt32 count;
err = queryMergeObj(db, query, props, count, mergeQueryTime);
MojTestErrCheck(err);
mergeTime = mergeQueryTime.microsecs();
err = MojPrintF(" merging with query - %d objects - of kind %s %llu times took: %llu microsecs\n", count, kindId, numBatchMergeIterations, mergeTime);
MojTestErrCheck(err);
err = MojPrintF(" time per merge: %llu microsecs\n", (mergeTime) / (numBatchMergeIterations));
MojTestErrCheck(err);
err = MojPrintF(" time per object: %llu microsecs", (mergeTime) / (count * numBatchMergeIterations));
MojTestErrCheck(err);
err = MojPrintF("\n\n");
MojTestErrCheck(err);
err = buf.format("Merge with query %s,,,,,\nMerge with query - %d objects - %llu times,%s,%llu,%llu,%llu,\n", queryStr.data(), count, numBatchMergeIterations, kindId, mergeTime, mergeTime/numBatchMergeIterations, mergeTime/(count*numBatchMergeIterations));
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
return MojErrNone;
}
示例5: UpdateSyncState
void SyncStateUpdater::UpdateSyncState(MojSignal<>::SlotRef slot, const SyncState& syncState, bool clearSyncState)
{
m_doneSignal.connect(slot);
MojErr err;
MojObject batchPayload;
MojObject batchOperations;
// Delete old sync state
MojObject delPayload;
MojDbQuery query;
err = query.from(SyncStateAdapter::SYNC_STATE_KIND);
ErrorToException(err);
MojString capabilityProvider;
capabilityProvider.assign(m_capabilityProvider.c_str());
err = query.where(SyncStateAdapter::CAPABILITY_PROVIDER, MojDbQuery::OpEq, capabilityProvider);
ErrorToException(err);
err = query.where(SyncStateAdapter::ACCOUNT_ID, MojDbQuery::OpEq, syncState.GetAccountId());
ErrorToException(err);
err = query.where(SyncStateAdapter::COLLECTION_ID, MojDbQuery::OpEq, syncState.GetCollectionId());
ErrorToException(err);
MojObject queryObj;
err = query.toObject(queryObj);
ErrorToException(err);
err = delPayload.put("query", queryObj);
ErrorToException(err);
MojObject delOperation;
err = delOperation.putString("method", "del");
ErrorToException(err);
err = delOperation.put("params", delPayload);
ErrorToException(err);
err = batchOperations.push(delOperation);
ErrorToException(err);
if(!clearSyncState) { // Store new sync state
MojObject putPayload;
MojObject syncStateObj;
SyncStateAdapter::SerializeToDatabaseObject(syncState, syncStateObj, m_capabilityProvider.c_str(), m_busAddress.c_str());
MojObject objects;
err = objects.push(syncStateObj);
ErrorToException(err);
err = putPayload.put("objects", objects);
ErrorToException(err);
MojObject putOperation;
err = putOperation.putString("method", "put");
ErrorToException(err);
err = putOperation.put("params", putPayload);
ErrorToException(err);
err = batchOperations.push(putOperation);
ErrorToException(err);
}
err = batchPayload.put("operations", batchOperations);
ErrorToException(err);
// Note: batch operations are not atomic, this is just for convenience and performance
m_busClient.SendRequest(m_updateSlot, "com.palm.tempdb", "batch", batchPayload);
}