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

问题描述 投票:2回答:1

我想让他们的祖先之间的所有类别项目成为具有特定“id”的祖先。

以下是来自/categories的GETting返回的其中一个类别的JSON:

{
        "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": []
    }

我想在/categories上使用where子句调用ancestors[x].id = "b27086d2-33f2-43c3-aad1-4c01b2b9a886" API,但是从documentation我不明白我应该如何编写查询谓词。

谁能帮我?

predicate commercetools sphere.io
1个回答
1
投票

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

试试吧

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

关心Brian

© www.soinside.com 2019 - 2024. All rights reserved.