java - 如何查询在 Parse 中设置为指向其他表的指针的列的值

标签 java android parsing 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());
                }
            }
        });

因此 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/

相关文章:

java - Hibernate 约束在级联保存时失败

java - Stack.capacity() 和 Stack.size() 的区别

android - Android 菜单中的 ResXMLTree_node header 大小 0x0 太小

android - 如何在 IntelliJ IDEA(社区版)中使用 Scala 源构建 Android 项目?

java - Android:如何将 JSON 数组解析为字符串

java - 在MongoDB中,Java驱动程序如何将 "explain"与聚合一起使用?

android - 检查用户何时启动了 android 浏览器

Java解析嵌套conf文件

Java解析JSON异常

java - 检索 Google 委托(delegate)联系人