2017-06-05 35 views
0

在Parse中進行查詢時,只下載ObjectIdPARSE.COM:查詢時獲取數據

有什麼辦法可以在同一個調用中下載所有的列數據?

如果沒有,最快的方法是獲取它?

這是我想出來的,但由於調用是一個接一個完成的,所以執行需要很長時間。

// Create query 
ParseUser user = ParseUser.getCurrentUser(); 
ParseQuery<Centro> query = ParseQuery.getQuery("..."); 
query.include(...); 
query.whereEqualTo(...); 
query.addAscendingOrder(...); 

// Execute query 
try { 
    CLASS = query.find(); 
} catch (ParseException e) { 
    return false; 
} 

// Force to fetch all data by reading a single column 
for (CLASS class : classes){ 
    try { 
     class.fetch(); 
     class.getSomething(); 
    } catch (ParseException e) { } 
} 

任何幫助表示讚賞,謝謝。

回答

0

include功能是用來告訴解析檢索其他表的內容也是如此。我想我必須在那裏輸入表名,但是,我必須輸入字段名稱。

鏈接的情況下,任何人的文檔的愛好:http://docs.parseplatform.org/android/guide/

我在下面的示例中實現,因爲Comment(表名)是大寫的,和線query.include("post")指定post小寫,它必須是一個字段名稱。

ParseQuery<ParseObject> query = ParseQuery.getQuery("Comment"); 

// Retrieve the most recent ones 
query.orderByDescending("createdAt"); 

// Only retrieve the last ten 
query.setLimit(10); 

// Include the post data with each comment 
query.include("post"); 

query.findInBackground(new FindCallback<ParseObject>() { 
    public void done(List<ParseObject> commentList, ParseException e) { 
    // commentList now contains the last ten comments, and the "post" 
    // field has been populated. For example: 
    for (ParseObject comment : commentList) { 
     // This does not require a network access. 
     ParseObject post = comment.getParseObject("post"); 
     Log.d("post", "retrieved a related post"); 
    } 
    } 
}); 
0

我不認爲是沒有得到,如果你組織你的查詢剛拿到的objectID如文檔,那麼你可以得到的東西是這樣的:

ParseQuery<ParseObject> query = ParseQuery.getQuery("FamousPerson"); 
query.whereEqualTo("name", "Donald Trump"); 
query.getFirstInBackground(new GetCallback<ParseObject>() { 
    public void done(ParseObject object, ParseException e) { 
    if (object == null) { 
     Log.d("person", "The getFirst request failed."); 
    } else { 
     String myJob = object.getString("Job") //equals "President" 

    } 
    } 
}); 
+0

確實,這是引用的數據,我錯過了,因爲在查詢中鍵入了'include'命令。 – JonZarate