predicate - Commercetools - 使用查询谓词过滤集合属性

标签 predicate commercetools sphere.io

我想获取在其祖先之间具有特定“id”的祖先的所有类别项目。

这是 返回的类别之一的 JSON获取 来自/categories :

{
        "id": "4627f3b0-fe52-4cc6-b03e-3fd72e701342",
        "version": 1,
        "lastMessageSequenceNumber": 1,
        "createdAt": "2019-02-18T13:48:51.677Z",
        "lastModifiedAt": "2019-02-18T13:48:51.677Z",
        "lastModifiedBy": {
            "clientId": "_anonymous"
        },
        "createdBy": {
            "clientId": "_anonymous"
        },
        "key": "snowboard-gloves",
        "name": {
            "en": "Snowboard Gloves"
        },
        "slug": {
            "en": "snowboard-gloves"
        },
        "description": {
            "en": "Gloves specifically designed for snowboarding"
        },
        "ancestors": [
            {
                "typeId": "category",
                "id": "b27086d2-33f2-43c3-aad1-4c01b2b9a886"
            }
        ],
        "parent": {
            "typeId": "category",
            "id": "b27086d2-33f2-43c3-aad1-4c01b2b9a886"
        },
        "orderHint": "0.000016",
        "metaTitle": {
            "en": "Snowboard Gloves"
        },
        "metaDescription": {
            "en": "Gloves specifically designed for snowboarding"
        },
        "assets": []
    }

我想调用/categoriesancestors[x].id = "b27086d2-33f2-43c3-aad1-4c01b2b9a886" 上带有 where 子句的 API但来自 documentation我不明白我应该如何编写查询谓词。

谁能帮我?

最佳答案

查询谓词遵循 json 响应的结构。使用 () 访问嵌套字段括号。

试试这个

ancestors(id = "idb27086d2-33f2-43c3-aad1-4c01b2b9a886")

关于predicate - Commercetools - 使用查询谓词过滤集合属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54751830/

相关文章:

swift - 在 Cloudkit 谓词上使用 OR 运算符

java - 更优雅的实现方式

list - 将列表 1 中的特定数字与列表 2 中的特定数字交换

java - 是否可以使用产品属性在 CT 中创建分面搜索?

java - Commercetools Sphereio SphereClient 为空

xml - 在 XQuery 中,如何根据给定谓词递归过滤后代?

java - 如何获取在我的 commercetools 项目中创建的所有 ProductType?

java - 我怎样才能通过他的variantKey找到一个ProductVariant?

java - 我们如何找到基于不完整名称的项目?

java - commercetools:如何使用 getDiscountedPricePerQuantity()?