vli*_*o20 10 java parsing android parse-platform
我正在使用Parse作为我的应用程序.我想查询一个表,其中列设置为指向其他表的指针.这是查询:
ParseQuery query = new ParseQuery("CategoryAttribute");
query.whereEqualTo("categoryId", categoryId);
query.findInBackground(new FindCallback() {
@Override
public void done(List<ParseObject> categoryAttributes, ParseException e) {
if (e == null) {
for (int i = 0; i < categoryAttributes.size(); i++){
String atributeCategoryId = categoryAttributes.get(i).getString("categoryId");
String attributeKey = categoryAttributes.get(i).getString("attributeKey");
String attributeValue = categoryAttributes.get(i).getString("attributeValue");
setCategoryAtributeRow(atributeCategoryId, attributeKey, attributeValue);
}
} else {
Log.d("score", "Error: " + e.getMessage());
}
}
});
Run Code Online (Sandbox Code Playgroud)
所以该categoryId列是指向其他表的指针.其他列工作正常.我试图扫描API和指南,但找不到所需的解决方案.非常感谢帮助!
vli*_*o20 13
以下是此解决方案:
首先,您需要根据ParseObject表的类型创建一个:
ParseObject sale = ParseObject.createParseObject("Sale");
Run Code Online (Sandbox Code Playgroud)
然后你需要得到ParseObject结果:
sale = result.getParseObject(pointer_field);
Run Code Online (Sandbox Code Playgroud)
现在,您可以从正常情况下的sale任何字段中拉出,例如:
sale.getString("some_field")
Run Code Online (Sandbox Code Playgroud)
注意: 在执行查询时,如果希望能够在返回查询后从中提取数据,则必须包含指针字段.结果:
query.include("pointer_field")
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你
| 归档时间: |
|
| 查看次数: |
12278 次 |
| 最近记录: |