REST API:人口和字段选择
🌐 REST API: Population & Field Selection
Page summary:使用
populate参数在 REST API 响应中包含关系、媒体字段、组件和动态区域。使用fields参数仅返回特定字段。🌐 Use the
populateparameter to include relations, media fields, components, and dynamic zones in REST API responses. Use thefieldsparameter to return only specific fields.
REST API 默认不会填充任何关联、媒体字段、组件或动态区域。使用 populate 参数 来填充特定字段。使用 fields 参数 仅返回查询结果中的特定字段。
🌐 The REST API by default does not populate any relations, media fields, components, or dynamic zones. Use the populate parameter to populate specific fields. Use the fields parameter to return only specific fields with the query results.
Strapi 利用 `qs` 库 解析嵌套对象的能力来创建更复杂的查询。
🌐 Strapi takes advantage of the ability of the `qs` library to parse nested objects to create more complex queries.
直接使用 qs 来生成复杂查询,而不是手动创建它们。本说明文档中的示例展示了如何使用 qs。
🌐 Use qs directly to generate complex queries instead of creating them manually. Examples in this documentation showcase how you can use qs.
如果你更喜欢使用我们的在线工具,而不是在你的机器上使用 qs 生成查询,你也可以使用 交互式查询构建器。
🌐 You can also use the interactive query builder if you prefer playing with our online tool instead of generating queries with qs on your machine.
字段选择
🌐 Field selection
查询可以接受一个 fields 参数来只选择某些字段。默认情况下,REST API 仅返回以下 类型的字段:
🌐 Queries can accept a fields parameter to select only some fields. By default, the REST API only returns the following types of fields:
- 字符串类型:
string