2014-11-06 78 views
0

我正在嘗試將表中的記錄保存到指向另一個表的指針字段但無法實現它的表中。通過解析Web應用程序,如果您複製表的objectID字段並將其粘貼到另一個表的指針字段,則會自動鏈接。使用解析保存對象記錄

下面有什麼,我試圖做一個例子:

public class insertRow { 

    *//Initialize parseObject* 
    ParseObject Comments = new ParseObject("Comments"); 

*Lets put some information on Comments table* 
    Comments.put("User","user name"); 
    Comments.put("Subject","Subject"); 
    Comments.put("Description","Description"); 
    Comments.put("Rate",3); 

    *//Here we want to link the actual record of Restaurant with the comment 
    //saving the objectID of Restaurant to the pointer field in Comments* 
    Comments.put("RestID","here comes ObjectID from table Restaurant"); 

    *//Saving data in background* 
    Comments.SaveInBackground(); 

}

關於餐廳的第一個表存儲的信息,有關Restaurant's評論其他商店的信息,所以我想要使用一對多關係進行鏈接,然後使用片段和帶有適配器的列表視圖顯示所有註釋。

我一直在閱讀和搜索信息和文檔。只要知道在存儲大量記錄的情況下使用指針會更好。我會很感激任何幫助或提示。謝謝所有

回答

0

終於可以通過這個。解析文檔是不是很清楚,但是使用一些文檔和選項,這是爲了節省對象的一種方法:

Comentario.put("RestID",ParseObject.createWithoutData("Restaurante",resid)); 

其中:

  • 渣油:在解析Comentario表表示指針對象場Restaurante表
  • resid:包含表Restaurante處記錄的objectId字符串的字段。

希望它可以幫助任何有類似的疑問怎麼辦