本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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.");
}