我正在尝试使用关系名称填充特定关系(categories
) 与 populate 参数结合使用,但它不会填充categories
.
当我查看架构时,我发现关系字段存在于属性对象中。但我的回复中仍然只得到非关系字段。
我尝试了上面提到的所有组合Strapi文档 https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/populating-fields.html#population但它们都不起作用。
The find
还为正在填充的内容类型启用了权限,在本例中为categories
.
/api/products?populate=*
/api/products?populate[0]=categories
/api/products?populate[categories]=*
我的产品架构
{
"kind": "collectionType",
"collectionName": "products",
"info": {
"singularName": "product",
"pluralName": "products",
"displayName": "Product",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"images": {
"type": "media",
"multiple": true,
"required": false,
"allowedTypes": [
"images"
]
},
"categories": {
"type": "relation",
"relation": "oneToMany",
"target": "api::category.category"
}
}
}
System
- 表带版本:
4.1.8
- NPM版本:
8.3.2
- Node.js 版本:
16.13.2
- 数据库:MySQL