Parse.com JS SDK 包含多个嵌套查询

Parse.com JS SDK multiple nested queries with include

设置:

查询应根据过滤器获取所有产品,即:

我有数组中的 ID,所以基本上我最终想要的是:

    SELECT * FROM products 
WHERE product.shop.id IS IN shop_ids && product.brand.id IS IN brand_ids

我不知道该怎么做,我尝试了以下方法来获取所有包含品牌 ID 的产品,这很有效。 但是 包含不起作用,另外 除了品牌,它应该检查产品是否在给定商店 ID 的列表中

            for (var i = 0; i < brand_ids.length; i++)
            {
                var query = new Parse.Query(product);
                var brand = new Brand();
                brand.id = brand_ids[i];
                query.equalTo('brand', brand);
                query.include('brand');
                query.include('shop'); //TODO: where shop is one of [ids]

                queries.push(query);
            };

您的代码基本上创建了一个查询列表,每个查询只能匹配一个 ID。您需要使用 containedIn API https://parse.com/docs/js/api/classes/Parse.Query.html#methods_containedIn。试试下面的代码:

var query = new Parse.Query(product);
var brands = [];
for (var i = 0; i < brand_ids.length; i++) {
    var brand = new Brand();
    brand.id = brand_ids[i];
    brands.push(brand);
};
query.containedIn('brand', brands);
query.include('brand');
query.include('shop'); //TODO: where shop is one of [ids]
query.find();