【问题标题】:How to Query pinned ParseObjects of different subclasses?如何查询不同子类的固定 ParseObjects?
【发布时间】:2016-01-14 06:27:05
【问题描述】:

我正在尝试在我的应用程序上创建一种“最近查看”功能。用户类有一个数组类型的列,我在其中存储指向 不同子类的 ParseObjects 的指针。

例如,

  1. 我有一个名为 Offers 的 ParseObject,我有另一个 ParseObject 称为 Products 的不同子类。
  2. 用户对象类中名为“RecentlyViewedItems”的数组包含这两种类型。
  3. 我在应用程序中获取该数组并将它们固定在本地。
  4. 我需要从固定列表中检索它们,我通常从 使用 ParseQuery 固定列表。但是这个特定的固定列表包含 不同类的 ParseObjects,据我所知 ParseQuery 只使用指定的子类,而不是泛化的 ParseObject。

那么,我如何从不同类型 ParseObjects 的固定列表中检索项目?

【问题讨论】:

    标签: java android parse-platform


    【解决方案1】:

    来自 pin 的查询类似于来自 parse 的查询。区别仅在于设置属性query.fromPin(); 因此,如果您的 pin 命名为 "RecentlyViewedItems",您的查询应如下所示:

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Offers");
    query.fromPin("RecentlyViewedItems");
    query.findInBackground(new FindCallback<ParseObject>() {
    public void done(List<ParseObject> scoreList, ParseException e) {
        if (e == null) {
            Log.d("score", "Retrieved " + scoreList.size() + " scores");
        } else {
            Log.d("score", "Error: " + e.getMessage());
        }
    }
    });
    

    More info...

    【讨论】:

      猜你喜欢
      • 2019-10-30
      • 1970-01-01
      • 1970-01-01
      • 2018-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-12
      • 1970-01-01
      相关资源
      最近更新 更多