predicate - Commercetools - 使用查询谓词过滤集合属性
问题描述
我想获取在其祖先之间具有特定“id”的祖先的所有类别项目。
以下是GET来自的返回的类别之一的 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": []
}
我想用where子句调用/categories
API,但从文档中我不明白我应该如何编写查询谓词。ancestors[x].id = "b27086d2-33f2-43c3-aad1-4c01b2b9a886"
谁能帮我?
解决方案
查询谓词遵循 json 响应的结构。嵌套字段使用()
方括号访问。
试试这个
ancestors(id = "idb27086d2-33f2-43c3-aad1-4c01b2b9a886")
推荐阅读
- visual-studio-code - Prettier Code Formatter 与 VSCode 中的默认代码格式化程序有何不同?
- clojure - 当查询关于所有属性时,Datomic 会隐藏部分历史记录
- python - SQLAlchemy 返回具有相同主键的数据计数
- bash - 为什么 bash 会吞下字符
- javascript - “const”外部组件和“static”内部组件之间的区别?
- amazon-dynamodb - DynamoDB 如何将嵌套列表保存为属性
- c - 在C中直接为变量赋值是否安全?
- pandas - 保存时熊猫特殊字符转换为奇怪的字符
- c# - 事件运行后释放 Inventor
- woocommerce - 无法访问 woocommerce shipping 的元数据