ios - 使用指针列表 (where, $in) 解析包含在中的查询约束

标签 ios objective-c parse-platform

我在 Parse 中有两个表:ProductIntroduction

Introduction 有一个指针列 product 和一个字符串列 status

enter image description here

我可以使用 GET 介绍请求 (Parse documentation) 中的以下参数轻松检索所有状态为“实时、已验证”的介绍:

{
    where =     {
        status =         {
            "$in" =             (
                live,
                validated
            );
        };
    };
}

现在,我想检索所有介绍,例如,所有产品 ID 等于“Jpun01VJ3c,AkxTvIdZTQ”。

我尝试了以下参数(我也尝试在 $in 中只使用一个 ObjectId 数组:“$in” = (Jpun01VJ3c, AkxTvIdZTQ);)。

{
    where =     {
        product =         {
            "$in" =             (
                                {
                    "__type" = Pointer;
                    className = Product;
                    objectId = Jpun01VJ3c;
                },
                                {
                    "__type" = Pointer;
                    className = Product;
                    objectId = AkxTvIdZTQ;
                }
            );
        };
    };
}

所以,问题是: 我们如何才能检索带有产品列表的介绍?

你有什么建议吗?

ps:像这样只检索特定产品的一个介绍是没有问题的:

{
    where =     {
        product =         {
            "__type" = Pointer;
            className = Product;
            objectId = Jpun01VJ3c;
        };
    };
}

谢谢

最佳答案

在这种情况下,您可能希望使用 matchesQuery 而不是 containedIn

以下代码是 JS 但易于翻译:

var productQuery = new Parse.Query("Product");
productQuery.containedIn("objectId", [ YOUR LIST OF IDs ]);

var introductionQuery = new ParseQuery("Introduction");
introductionQuery.matchesQuery("product", productQuery);
introductionQuery
  .find()
  .then(function(introductions) {
    [...]
  });

有关 iOS 的更多信息:https://parseplatform.github.io/Parse-SDK-iOS-OSX/api/Classes/PFQuery.html#/c:objc(cs)PFQuery(im)whereKey:matchesQuery :

关于ios - 使用指针列表 (where, $in) 解析包含在中的查询约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42000698/

相关文章:

android - Parse.com 无法将通知推送到多个设备 android

ios - 如何检查对象是否被快速拖动?

ios - 将语言从(英语)更改为阿拉伯语时,如何从左到右更改 SWReaveal 侧边菜单形式

ios - 替换 UITextView 的部分属性文本

javascript - 如何使用 Parse 密码重置

ios - 在 iOS/Objective C 下输入的日期和时间是 1 小时或休息日

ios - libMobileGestalt MobileGestalt.c :890: MGIsDeviceOneOfType is not supported on this platform

我的二进制忽略设置的 iOS 最低操作系统要求

ios - 如何将 iOS 应用程序中创建的文件传输到 Mac

iphone - 如何将图像保存到相机胶卷?