1

我正在尝试使用商务工具查询自定义字段。给定一个对象如下

{
  [...]
  "custom": {
    "type": {
      "key": "my-category"
    },
    "fields": {
      "returns": [
                    {obj:  {readStatus: "random"},
                    {travelDestination:"randomTravelDestination"}

                 ],
      "description": "example description"
    }
  }
}

例如,我可以通过简单的查询轻松获取描述值:

custom(fields(description="example description"))

文档:https ://docs.commercetools.com/api/projects/custom-fields 。

但是,我将如何编写查询来获取readStatus. 我特别想看看如何查询具有多个值的数组中的内容?

4

1 回答 1

1

由于您的示例有点令人困惑,您是否还有其他要查询的完整对象示例?如果订单上的自定义类型的自定义字段定义如下所示:

{
      "name": "shippingAddressPerLineItem",
      "label": {
        "en": "shippingAddressPerLineItem"
      },
      "required": false,
      "type": {
        "name": "Set",
        "elementType": {
          "name": "String"
        }
      },
      "inputHint": "SingleLine"
    }    

订单看起来像这样(这里删除了一些字段):

{
  "type": "Order",
  "id": "a67e28b0-15fb-40a9-bd44-1c70dbeb7dd1",
  "version": 5,
  "custom": {
    "type": {
      "typeId": "type",
      "id": "e4a75e6f"
    },
    "fields": {
      "shippingAddressPerLineItemV2": [
        "item2",
        "item1",
        "address2",
        "Address1"
      ]
    }
  }
}

用于查找集合中值为“item2”的订单的订单查询谓词如下所示:

自定义(字段(shippingAddressPerLineItem = “item2”))

于 2021-03-03T17:23:52.493 回答