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


Java QueryRow.getDocument方法代码示例

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


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

示例1: getContactDocumentByEmail

import com.couchbase.lite.QueryRow; //导入方法依赖的package包/类
public Document getContactDocumentByEmail(String email) {
    Query query = contactView.createQuery();
    query.setStartKey(email);
    query.setEndKey(email);
    QueryEnumerator enumerator;
    try {
        enumerator = query.run();
    } catch (CouchbaseLiteException e) {
        throw new RuntimeException(e);
    }
    Document ret = null;
    if (enumerator.hasNext()) {
        QueryRow row = enumerator.next();
        ret = row.getDocument();
    }
    return ret;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:18,代码来源:DataServiceImpl.java

示例2: getGameDocumentByModelId

import com.couchbase.lite.QueryRow; //导入方法依赖的package包/类
public Document getGameDocumentByModelId(String id) {
    Query query = gameView.createQuery();
    query.setStartKey(id);
    query.setEndKey(id);
    query.setEndKey(id);
    QueryEnumerator enumerator;
    try {
        enumerator = query.run();
    } catch (CouchbaseLiteException e) {
        throw new RuntimeException(e);
    }
    Document ret = null;
    if (enumerator.hasNext()) {
        QueryRow row = enumerator.next();
        ret = row.getDocument();
    }
    return ret;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:19,代码来源:DataServiceImpl.java

示例3: onItemClick

import com.couchbase.lite.QueryRow; //导入方法依赖的package包/类
/**
 * Handle click on item in list
 */
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {

    // Step 10 code goes here
    // This code handles checkbox touches.  Couchbase Lite documents are like versioned-maps.
    // To change a Document, add a new Revision.
    QueryRow row = (QueryRow) adapterView.getItemAtPosition(position);
    Document document = row.getDocument();
    Map<String, Object> newProperties = new HashMap<String, Object>(document.getProperties());

    boolean checked = ((Boolean) newProperties.get("check")).booleanValue();
    newProperties.put("check", !checked);

    try {
        document.putProperties(newProperties);
        kitchenSyncArrayAdapter.notifyDataSetChanged();
    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), "Error updating database, see logs for details", Toast.LENGTH_LONG).show();
        Log.e(TAG, "Error updating database", e);
    }

}
 
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:25,代码来源:MainActivity.java

示例4: queryItemsByIds

import com.couchbase.lite.QueryRow; //导入方法依赖的package包/类
/**
 * 查询指定的json对象,以字符串形式返回
 * view 查询的version 为1
 *
 * @param ids
 * @param dataType
 * @return
 */


@Override
public List<Map<String, Object>> queryItemsByIds(final String dataType, Object... ids) {

    List<Map<String, Object>> datas = new ArrayList<>();

    View phoneView = mDatabase.getView(dataType);

    if (phoneView != null) {
        //建立索引,只建立一次
        indexView(phoneView, dataType);

        Query query = phoneView.createQuery();
        query.setKeys(Arrays.<Object>asList(ids));
        query.setLimit(ids.length);
        try {
            QueryEnumerator qe = query.run();
            for (Iterator<QueryRow> it = qe; it.hasNext(); ) {
                QueryRow row = it.next();
                Document doc = row.getDocument();
                Map<String, Object> map = doc.getProperties();
                if (map != null && map.size() > 0) {
                    datas.add(map);
                }
            }


        } catch (Exception e) {
            LogUtils.e(e);
        }
    }


    return datas;
}
 
开发者ID:jessie345,项目名称:RealArchitecture,代码行数:45,代码来源:CouchBaseStorage.java

示例5: queryItemsByTypes

import com.couchbase.lite.QueryRow; //导入方法依赖的package包/类
@Override
public List<Map<String, Object>> queryItemsByTypes(final String dataType) {

    List<Map<String, Object>> datas = new ArrayList<>();

    View phoneView = mDatabase.getView(dataType);

    if (phoneView != null) {
        //建立索引,只建立一次
        indexView(phoneView, dataType);

        Query query = phoneView.createQuery();
        try {
            QueryEnumerator qe = query.run();
            for (Iterator<QueryRow> it = qe; it.hasNext(); ) {
                QueryRow row = it.next();
                Document doc = row.getDocument();
                Map<String, Object> map = doc.getProperties();
                if (map != null && map.size() > 0) {
                    datas.add(map);
                }
            }


        } catch (Exception e) {
            LogUtils.e(e);
            String s = e.getMessage();
        }
    }


    return datas;
}
 
开发者ID:jessie345,项目名称:RealArchitecture,代码行数:34,代码来源:CouchBaseStorage.java

示例6: indexedStringEntityQueriesRun

import com.couchbase.lite.QueryRow; //导入方法依赖的package包/类
private void indexedStringEntityQueriesRun(View indexedStringView, int count)
        throws CouchbaseLiteException {
    // create entities
    String[] fixedRandomStrings = StringGenerator.createFixedRandomStrings(count);
    database.beginTransaction();
    for (int i = 0; i < count; i++) {
        Document entity = database.getDocument(String.valueOf(i));
        Map<String, Object> properties = new HashMap<>();
        properties.put("indexedString", fixedRandomStrings[i]);
        entity.putProperties(properties);
    }
    database.endTransaction(true);
    log("Built and inserted entities.");

    // query for entities by indexed string at random
    int[] randomIndices = StringGenerator.getFixedRandomIndices(getQueryCount(), count - 1);

    // clear the document cache to force loading properties from the database
    database.clearDocumentCache();

    startClock();
    for (int i = 0; i < getQueryCount(); i++) {
        int nextIndex = randomIndices[i];
        List<Object> keyToQuery = new ArrayList<>(1);
        keyToQuery.add(fixedRandomStrings[nextIndex]);

        Query query = indexedStringView.createQuery();
        query.setKeys(keyToQuery);
        QueryEnumerator result = query.run();
        while (result.hasNext()) {
            QueryRow row = result.next();
            //noinspection unused
            Document document = row.getDocument();
        }
    }
    stopClock(Benchmark.Type.QUERY_INDEXED);

    // delete all entities
    deleteAll();
    log("Deleted all entities.");
}
 
开发者ID:greenrobot,项目名称:android-database-performance,代码行数:42,代码来源:PerfTestCouchbase.java


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