2016-04-28 59 views
0
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將其存儲在任務類對象中?我希望我的查詢只能在列表視圖中列出。我正在研究使用Cloudant syn的Bluemix。如何使用Bluemix中的QueryResult獲取BasicDocumentRevision

+0

我不完全知道什麼是問。你能夠得到查詢結果,但無法填充你的任務對象? – markwatsonatx

回答

0

您可以通過循環QueryResult對象以獲得更多的QueryResult文件修訂版:

for(DocumentRevision rev : result){ 
    Task t = Task.fromRevision(rev); 
    if(task != null) 
     tasks.add(t); 
} 
相關問題