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


C++ MojDbQuery::where方法代码示例

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


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

示例1: BuildAccountPrefsWatch

void ActivityBuilderFactory::BuildAccountPrefsWatch(ActivityBuilder& builder, MojObject& accountRev)
{
	MojString name;
	GetAccountPrefsWatchActivityName(name);

	MojString desc;
	GetAccountPrefsWatchActivityDesc(desc);

	builder.SetName(name.data());
	builder.SetDescription(desc.data());
	builder.SetPersist(true);
	builder.SetExplicit(true);
	builder.SetImmediate(true, "low");

	MojDbQuery trigger;
	MojErr err = trigger.from(PopAccountAdapter::POP_ACCOUNT_KIND);
	ErrorToException(err);
	err = trigger.where(PopAccountAdapter::ACCOUNT_ID, MojDbQuery::OpEq, m_accountId);
	ErrorToException(err);
	err = trigger.where("_revPop", MojDbQuery::OpGreaterThan, accountRev);
	ErrorToException(err);
	builder.SetDatabaseWatchTrigger(trigger);

	MojObject params;
	err = params.put(PopAccountAdapter::ACCOUNT_ID, m_accountId);
	ErrorToException(err);
	builder.SetCallback(ACCOUNT_PREFS_WATCH_CALLBACK, params);

	MojObject metadata;
	err = metadata.put(PopAccountAdapter::ACCOUNT_ID, m_accountId);
	ErrorToException(err);
	builder.SetMetadata(metadata);
}
开发者ID:hatsada1,项目名称:app-services,代码行数:33,代码来源:ActivityBuilderFactory.cpp

示例2: GetSentEmails

void MojoDatabase::GetSentEmails(Signal::SlotRef slot, const MojObject& outboxFolderId, MojInt32 limit)
{
	MojErr err;

	MojDbQuery query;
	err = query.from(EmailSchema::Kind::EMAIL);
	ErrorToException(err);

	err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, outboxFolderId);
	ErrorToException(err);

	MojString sendStatus;
	err = sendStatus.format("%s.%s",EmailSchema::SEND_STATUS, EmailSchema::SendStatus::SENT);
	ErrorToException(err);
	err = query.where(sendStatus.data(), MojDbQuery::OpEq, true);
	ErrorToException(err);

	// Set limit
	if(limit > 0) {
		query.limit(limit);
	}

	slot.cancel(); // cancel existing slot in case we're in a callback
	err = m_dbClient.find(slot, query);
	ErrorToException(err);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:26,代码来源:MojoDatabase.cpp

示例3: GetAutoDownloadEmails

void MojoDatabase::GetAutoDownloadEmails(Signal::SlotRef slot, const MojObject& folderId, const MojInt64& rev, MojDbQuery::Page& page, MojInt32 limit)
{
	MojDbQuery query;

	MojErr err = query.from(PopEmailAdapter::POP_EMAIL_KIND);
	ErrorToException(err);

	err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, folderId);
	ErrorToException(err);
	
	if (rev > 0) {
		err = query.where(PopFolderAdapter::LAST_SYNC_REV, MojDbQuery::OpGreaterThan, rev);
		ErrorToException(err);
	}

	query.page(page);

	// Sort by timestamp descending
	err = query.order(EmailSchema::TIMESTAMP);
	ErrorToException(err);
	query.desc(true);

	// Set limit
	if(limit > 0) {
		query.limit(limit);
	}

	slot.cancel();
	err = m_dbClient.find(slot, query);
	ErrorToException(err);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:31,代码来源:MojoDatabase.cpp

示例4: BuildPreferencesWatch

void ImapActivityFactory::BuildPreferencesWatch(ActivityBuilder& ab, const MojObject& accountId, MojInt64 rev)
{
	MojErr err;

	ab.SetName( GetPreferencesWatchName(accountId) );
	ab.SetDescription("IMAP account preferences watch");
	ab.SetPersist(true);
	ab.SetForeground(true);

	// Metadata
	MojObject metadata;
	SetMetadata(metadata, PREFS_WATCH_NAME, accountId);
	ab.SetMetadata(metadata);

	MojDbQuery trigger;
	err = trigger.from(ImapAccountAdapter::SCHEMA);
	ErrorToException(err);
	err = trigger.where(ImapAccountAdapter::ACCOUNT_ID, MojDbQuery::OpEq, accountId);
	ErrorToException(err);
	err = trigger.where(ImapAccountAdapter::CONFIG_REV, MojDbQuery::OpGreaterThan, rev);
	ErrorToException(err);
	ab.SetDatabaseWatchTrigger(trigger);

	MojObject params;
	err = params.put("accountId", accountId);
	ErrorToException(err);

	ab.SetCallback(PREFS_WATCH_CALLBACK, params);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:29,代码来源:ImapActivityFactory.cpp

示例5: buildSample

TEST_F(ReqSuite, original)
{
    buildSample();
    mark1();

    // test visibility with update
    {
        MojDbReq req;

        // start transaction
        req.begin(&db, false);
        mark2(req);

        // visible within transaction
        checkMarkWithUpdate(50ul, -2, req);
    }

    // invisible after aborted transaction
    checkMarkWithUpdate(0ul, -2);

    // test visibility with delete
    mark1();
    {
        MojDbReq req;
        // start transaction
        req.begin(&db, false);

        deleteMark(50ul, -1, req);

        // visible within transaction
        {
            MojDbQuery query;
            MojAssertNoErr( query.from(_T("Test:1")) );
            MojAssertNoErr( query.where(_T("bar"), MojDbQuery::OpLessThan, 2) );

            MojObject update;

            MojUInt32 count = 0xbaddcafe;
            MojAssertNoErr( db.merge(query, update, count, MojDb::FlagNone, req) );
            EXPECT_EQ( 33ul, count);
        }
    }

    // invisible after aborted transaction
    {
        MojDbQuery query;
        MojAssertNoErr( query.from(_T("Test:1")) );
        MojAssertNoErr( query.where(_T("bar"), MojDbQuery::OpLessThan, 2) );

        MojObject update;
        // Note: should not set value to something that will introduce double-update

        MojUInt32 count = 0xbaddcafe;
        MojAssertNoErr( db.merge(query, update, count) );

        EXPECT_EQ( 83ul, count);
    }
}
开发者ID:KyleMaas,项目名称:db8,代码行数:58,代码来源:ReqTest.cpp

示例6: cancelTest

MojErr MojDbWatchTest::cancelTest(MojDb& db)
{
    // cancel find
    MojDbQuery query;
    MojErr err = query.from(_T("WatchTest:1"));
    MojTestErrCheck(err);
    err = query.where(_T("foo"), MojDbQuery::OpLessThanEq, 45);
    MojTestErrCheck(err);
    MojRefCountedPtr<TestWatcher> watcher(new TestWatcher);
    MojTestAssert(watcher.get());
    watcher->m_slot.cancel();
    MojDbCursor cursor;
    err = db.find(query, cursor, watcher->m_slot);
    MojTestErrCheck(err);
    err = cursor.close();
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 0);
    watcher->m_slot.cancel();
    MojTestAssert(watcher->m_count == 0);
    MojObject id;
    err = put(db, 1, 1, id, m_rev);
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 0);
    // cancel watch
    watcher.reset(new TestWatcher);
    MojTestAssert(watcher.get());
    MojDbQuery queryWithRev;
    err = queryWithRev.from(_T("WatchTest:1"));
    MojTestErrCheck(err);
    err = queryWithRev.where(_T("foo"), MojDbQuery::OpEq, 45);
    MojTestErrCheck(err);
    err = queryWithRev.where(_T("_rev"), MojDbQuery::OpGreaterThan, m_rev);
    MojTestErrCheck(err);
    bool fired = false;
    err = db.watch(queryWithRev, cursor, watcher->m_slot, fired);
    MojTestErrCheck(err);
    err = cursor.close();
    MojTestErrCheck(err);
    MojTestAssert(!fired);
    MojTestAssert(watcher->m_count == 0);
    watcher->m_slot.cancel();
    MojTestAssert(watcher->m_count == 0);
    err = put(db, 45, 45, id, m_rev);
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 0);

    return MojErrNone;
}
开发者ID:halfhalo,项目名称:db8,代码行数:48,代码来源:MojDbWatchTest.cpp

示例7: GetEmailsToMove

void MojoDatabase::GetEmailsToMove(Signal::SlotRef slot, const MojObject& accountId)
{
	MojErr err;

	MojDbQuery query;
	err = query.from(PopEmailAdapter::POP_EMAIL_KIND);
	ErrorToException(err);

	err = query.select(PopEmailAdapter::ID);
	ErrorToException(err);

	err = query.select("folderId");
	ErrorToException(err);

	err = query.select("destFolderId");
	ErrorToException(err);

	err = query.select("flags");
	ErrorToException(err);

	err = query.select(PopEmailAdapter::SERVER_UID);
	ErrorToException(err);

	err = query.where("destFolderId", MojDbQuery::OpNotEq, MojObject());
	ErrorToException(err);

	slot.cancel();
	err = m_dbClient.find(slot, query);
	ErrorToException(err);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:30,代码来源:MojoDatabase.cpp

示例8: BuildDeleteEmailsWatch

void ActivityBuilderFactory::BuildDeleteEmailsWatch(ActivityBuilder& builder)
{
	MojString name;
	GetDeleteEmailsActivityName(name);

	MojString desc;
	GetDeleteEmailsActivityDesc(desc);

	builder.SetName(name.data());
	builder.SetDescription(desc.data());
	builder.SetPersist(true);
	builder.SetExplicit(true);
	builder.SetImmediate(true, "low");

	// setup trigger
	MojDbQuery trigger;
	MojErr err = trigger.from(PopEmailAdapter::POP_EMAIL_KIND);
	ErrorToException(err);
	err = trigger.where("_del", MojDbQuery::OpEq, true);
	ErrorToException(err);
	builder.SetDatabaseWatchTrigger(trigger);

	// setup parameters (to be sent when trigger is called)
	MojObject params;
	err = params.put(PopFolderAdapter::ACCOUNT_ID, m_accountId);
	ErrorToException(err);
	builder.SetCallback(DELETE_EMAILS_CALLBACK, params);

	// put accountId in metadata
	MojObject metadata;
	err = metadata.put(PopFolderAdapter::ACCOUNT_ID, m_accountId);
	ErrorToException(err);
	builder.SetMetadata(metadata);
}
开发者ID:hatsada1,项目名称:app-services,代码行数:34,代码来源:ActivityBuilderFactory.cpp

示例9: GetEmailsToDelete

void MojoDatabase::GetEmailsToDelete(Signal::SlotRef slot)
{
	MojErr err;

	MojDbQuery query;
	err = query.from(PopEmailAdapter::POP_EMAIL_KIND);
	ErrorToException(err);

	err = query.select(PopEmailAdapter::ID);
	ErrorToException(err);

	err = query.select(PopEmailAdapter::SERVER_UID);
	ErrorToException(err);

	err = query.select(EmailSchema::FOLDER_ID);
	ErrorToException(err);

	err = query.where("_del", MojDbQuery::OpEq, true);
	ErrorToException(err);

	query.includeDeleted(true);

	slot.cancel();
	err = m_dbClient.find(slot, query);
	ErrorToException(err);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:26,代码来源:MojoDatabase.cpp

示例10: getAccountInfoResult

MojErr  OnEnabledHandler::getAccountInfoResult(MojObject& payload, MojErr resultErr)
{
	MojLogTrace(IMServiceApp::s_log);
	IMServiceHandler::logMojObjectJsonString(_T("OnEnabledHandler::getAccountInfoResult payload: %s"), payload);

	if (resultErr != MojErrNone) {
		MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler getAccountInfo result error %d"), resultErr);
		return resultErr;
	}

	MojObject result;
	MojErr err = payload.getRequired("result", result);
	if (err != MojErrNone || result.empty()) {
		MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler::getAccountInfoResult result empty or error %d"), err);
		return err;
	}

	err = result.getRequired("_id", m_accountId);
	if (err != MojErrNone || m_accountId.empty()) {
		MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler::getAccountInfoResult accountId empty or error %d"), err);
		return err;
	}

	err = result.getRequired("username", m_username);
	if (err != MojErrNone || m_username.empty()) {
		MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler::getAccountInfoResult username empty or error %d"), err);
		return err;
	}

    {
        MojObject capabilities;
        MojObject messagingObject;
        result.get("capabilityProviders", capabilities);
        getMessagingCapabilityObject(capabilities, messagingObject);
        err = messagingObject.getRequired("serviceName", m_serviceName);
        if (m_serviceName.empty()) {
            MojLogError(IMServiceApp::s_log, _T("OnEnabledHandler::getAccountInfoResult serviceName empty"));
            return err;
        }
    }

    if (m_enable)
    {
        MojDbQuery query;
        query.from("com.palm.config.libpurple:1");
        query.where("accountId", MojDbQuery::OpEq, m_accountId);
        query.limit(1);
        err = m_dbClient.find(m_getAccountConfigSlot, query);
    }
    else
    {
        err = accountDisabled();
    }

	return err;
}
开发者ID:webOS-ports,项目名称:imlibpurpleservice,代码行数:56,代码来源:OnEnabledHandler.cpp

示例11: deleteMark

    void deleteMark(MojUInt32 expect = 50ul, int mark = -1, MojDbReqRef req = MojDbReq())
    {
        MojDbQuery query;
        MojAssertNoErr( query.from(_T("Test:1")) );
        MojAssertNoErr( query.where(_T("bar"), MojDbQuery::OpEq, mark) );

        MojUInt32 count = 0xbaddcafe;
        MojAssertNoErr( db.del(query, count, MojDb::FlagNone, req) );
        EXPECT_EQ( expect, count );
    }
开发者ID:KyleMaas,项目名称:db8,代码行数:10,代码来源:ReqTest.cpp

示例12: GetEmailSyncList

void MojoDatabase::GetEmailSyncList(Signal::SlotRef slot, const MojObject& folderId, const MojInt64& rev, bool desc, MojDbQuery::Page& page, MojInt32 limit)
{
	MojErr err;

	MojDbQuery query;
	err = query.from(PopEmailAdapter::POP_EMAIL_KIND);//EmailSchema::Kind::EMAIL);
	ErrorToException(err);

	// Select relevant fields
	err = query.select(PopEmailAdapter::ID);
	ErrorToException(err);

	err = query.select(PopEmailAdapter::SERVER_UID);
	ErrorToException(err);

	err = query.select(EmailSchema::TIMESTAMP);
	ErrorToException(err);

	err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, folderId);
	ErrorToException(err);

	if (rev > 0) {
		err = query.where(PopFolderAdapter::LAST_SYNC_REV, MojDbQuery::OpGreaterThan, rev);
		ErrorToException(err);
	}

	query.page(page);

	// Sort by timestamp descending
	err = query.order(EmailSchema::TIMESTAMP);
	ErrorToException(err);
	query.desc(desc);

	// Set limit
	if(limit > 0) {
		query.limit(limit);
	}

	slot.cancel(); // cancel existing slot in case we're in a callback

	err = m_dbClient.find(slot, query);
	ErrorToException(err);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:43,代码来源:MojoDatabase.cpp

示例13: findAccountIdForRemoveResult

/*
 * Result of query for loginState entry with given username and serviceName when removing a buddy
 *
 * Remove buddy from buddyStatus and contact DB
 */
MojErr SendOneCommandHandler::findAccountIdForRemoveResult(MojObject& result, MojErr findErr)
{

	if (findErr) {

		MojString error;
		MojErrToString(findErr, error);
		MojLogError(IMServiceApp::s_log, _T("findAccountIdResult failed: error %d - %s"), findErr, error.data());

	} 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_buddyName);
			query.where("accountId", MojDbQuery::OpEq, m_accountId);
			query.from(IM_BUDDYSTATUS_KIND);

			// call del
			// virtual MojErr del(Signal::SlotRef handler, const MojDbQuery& query,
			//					   MojUInt32 flags = MojDb::FlagNone);
			MojErr err = m_tempdbClient.del(m_removeBuddySlot, query);
			if (err) {
				MojString error;
				MojErrToString(err, error);
				MojLogError(IMServiceApp::s_log, _T("removeBuddy: dbClient.del() failed: error %d - %s"), err, error.data());
				// tell the outgoing Command handler we are done
				m_outgoingIMHandler->messageFinished();
			}
		}
		else {
			MojLogError(IMServiceApp::s_log, _T("findAccountIdResult: no matching loginState record found for %s %s"), m_username.data(), m_serviceName.data());
			// tell the outgoing Command handler we are done
			m_outgoingIMHandler->messageFinished();
		}
	}

	return MojErrNone;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:48,代码来源:SendOneCommandHandler.cpp

示例14: BuildSentEmailsWatch

void ActivityBuilderFactory::BuildSentEmailsWatch(ActivityBuilder& builder, const MojObject& outboxFolderId, const MojObject& sentFolderId)
{
	// activity to setup watch
	MojString name;
	GetSentEmailsWatchActivityName(name);

	// description of watch
	MojString desc;
	GetSentEmailsWatchActivityDesc(desc);

	builder.SetName(name.data());
	builder.SetDescription(desc.data());
	builder.SetPersist(true);
	builder.SetExplicit(true);
	builder.SetForeground(true);

	// setup trigger
	MojDbQuery trigger;
	MojErr err = trigger.from(EmailSchema::Kind::EMAIL);
	ErrorToException(err);
	err = trigger.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, outboxFolderId);
	ErrorToException(err);
	err = trigger.where("sendStatus.sent", MojDbQuery::OpEq, true);
	ErrorToException(err);
	builder.SetDatabaseWatchTrigger(trigger);

	// setup parameters (to be sent when trigger is called)
	MojObject params;
	err = params.put(PopFolderAdapter::ACCOUNT_ID, m_accountId);
	ErrorToException(err);
	err = params.put(PopFolderAdapter::OUTBOX_FOLDER_ID, outboxFolderId);
	ErrorToException(err);
	err = params.put(PopFolderAdapter::SENT_FOLDER_ID, sentFolderId);
	ErrorToException(err);
	builder.SetCallback(SENT_EMAILS_WATCH_CALLBACK, params);

	// put accountId in metadata
	MojObject metadata;
	err = metadata.put("accountId", m_accountId);
	ErrorToException(err);
	builder.SetMetadata(metadata);
}
开发者ID:hatsada1,项目名称:app-services,代码行数:42,代码来源:ActivityBuilderFactory.cpp

示例15: rangeTest

MojErr MojDbWatchTest::rangeTest(MojDb& db)
{
    MojDbQuery query;
    MojErr err = query.from(_T("WatchTest:1"));
    MojTestErrCheck(err);
    err = query.where(_T("foo"), MojDbQuery::OpGreaterThan, 5);
    MojTestErrCheck(err);
    err = query.where(_T("foo"), MojDbQuery::OpLessThan, 100);
    MojTestErrCheck(err);
    MojRefCountedPtr<TestWatcher> watcher(new TestWatcher);
    MojTestAssert(watcher.get());
    MojDbCursor cursor;
    err = db.find(query, cursor, watcher->m_slot);
    MojTestErrCheck(err);
    err = cursor.close();
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 0);
    MojObject id;
    MojInt64 rev;
    err = put(db, 5, 5, id, rev);
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 0);
    err = put(db, 100, 100, id, rev);
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 0);
    err = put(db, 6, 6, id, rev);
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 1);
    watcher.reset(new TestWatcher);
    MojTestAssert(watcher.get());
    err = db.find(query, cursor, watcher->m_slot);
    MojTestErrCheck(err);
    err = cursor.close();
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 0);
    err = put(db, 99, 99, id, rev);
    MojTestErrCheck(err);
    MojTestAssert(watcher->m_count == 1);

    return MojErrNone;
}
开发者ID:halfhalo,项目名称:db8,代码行数:41,代码来源:MojDbWatchTest.cpp


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