我正在使用 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());
}
}
});
因此 categoryId
列是指向其他表的指针。其他列工作正常。
我试图扫描 API 和指南,但找不到所需的解决方案。帮助将不胜感激!
最佳答案
解决方法如下:
首先,您需要根据表的类型创建一个 ParseObject
:
ParseObject sale = ParseObject.createParseObject("Sale");
然后您需要从结果中获取ParseObject
:
sale = result.getParseObject(pointer_field);
现在您可以像往常一样从 sale
中提取任何字段,例如:
sale.getString("some_field")
注意: 当您进行查询时,如果您希望能够在返回查询后从中提取数据,则必须包含指针字段。结果:
query.include("pointer_field")
希望对你有帮助
关于java - 如何查询在 Parse 中设置为指向其他表的指针的列的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15517541/