模块
¥Models
Page summary:
Models define Strapi’s content structure via content-types and reusable components. This documentation walks through creating these models in the Content-type Builder or CLI and managing schema files with optional lifecycle hooks.
由于 Strapi 是一个无头内容管理系统 (CMS),因此为内容创建内容结构是使用该软件的最重要方面之一。模型定义内容结构的表示。
¥As Strapi is a headless Content Management System (CMS), creating a content structure for the content is one of the most important aspects of using the software. Models define a representation of the content structure.
Strapi 有 2 种不同类型的模型:
¥There are 2 different types of models in Strapi:
-
内容类型,可以是集合类型或单一类型,具体取决于它们管理的条目数量,
¥content-types, which can be collection types or single types, depending on how many entries they manage,
-
以及可在多种内容类型中重复使用的内容结构组件。
¥and components that are content structures re-usable in multiple content-types.
如果你刚刚开始,直接在管理面板中使用 内容类型生成器 生成一些模型会很方便。用户界面接管了大量验证任务,并展示了创建内容结构的所有可用选项。然后可以使用此文档在代码级别查看生成的模型映射。
¥If you are just starting out, it is convenient to generate some models with the Content-type Builder directly in the admin panel. The user interface takes over a lot of validation tasks and showcases all the options available to create the content's content structure. The generated model mappings can then be reviewed at the code level using this documentation.