如何使用 Bluemix 中的 QueryResult 获取 BasicDocumentRevision
How to use the QueryResult in Bluemix to get the BasicDocumentRevision
public List<Task> allTasks() {
int nDocs = this.mDatastore.getDocumentCount();
List<BasicDocumentRevision> all = this.mDatastore.getAllDocuments(0, nDocs, true);
List<Task> tasks = new ArrayList<Task>();
// Filter all documents down to those of type Task.
IndexManager im = new IndexManager(mDatastore);
List<Object> indexFields = new ArrayList<Object>();
indexFields.add("city");
indexFields.add("price");
indexFields.add("Area");
indexFields.add("Information");
indexFields.add("imagename");
// Create the index
im.ensureIndexed(indexFields);
Map<String, Object> query = new HashMap<String, Object>();
query.put("desc", "RESIDENTIAL PROPERTY");
QueryResult result = im.find(query);
for(BasicDocumentRevision rev :all) {
Task t = Task.fromRevision(rev);
if (t != null) {
tasks.add(t);
}
}
return tasks;
如何使用 queryresult 将其存储在任务 class 对象中?我希望我的查询仅在列表视图中列出。我正在使用 Cloudant syn 开发 Bluemix。
您可以通过遍历 QueryResult
对象从 QueryResult
获取文档修订版,例如:
for(DocumentRevision rev : result){
Task t = Task.fromRevision(rev);
if(task != null)
tasks.add(t);
}
public List<Task> allTasks() {
int nDocs = this.mDatastore.getDocumentCount();
List<BasicDocumentRevision> all = this.mDatastore.getAllDocuments(0, nDocs, true);
List<Task> tasks = new ArrayList<Task>();
// Filter all documents down to those of type Task.
IndexManager im = new IndexManager(mDatastore);
List<Object> indexFields = new ArrayList<Object>();
indexFields.add("city");
indexFields.add("price");
indexFields.add("Area");
indexFields.add("Information");
indexFields.add("imagename");
// Create the index
im.ensureIndexed(indexFields);
Map<String, Object> query = new HashMap<String, Object>();
query.put("desc", "RESIDENTIAL PROPERTY");
QueryResult result = im.find(query);
for(BasicDocumentRevision rev :all) {
Task t = Task.fromRevision(rev);
if (t != null) {
tasks.add(t);
}
}
return tasks;
如何使用 queryresult 将其存储在任务 class 对象中?我希望我的查询仅在列表视图中列出。我正在使用 Cloudant syn 开发 Bluemix。
您可以通过遍历 QueryResult
对象从 QueryResult
获取文档修订版,例如:
for(DocumentRevision rev : result){
Task t = Task.fromRevision(rev);
if(task != null)
tasks.add(t);
}