documentId 解释:从 Strapi v4 替换 id
在以前的 Strapi 版本中,id 的概念(既用于内容 API,也用作数据库行标识符)并不总是稳定:单个条目可能有多个版本或本地化,其数字标识符 id 在复制或导入/导出操作等情况下可能会发生变化。
🌐 In previous Strapi versions, the concept of id (used both in the Content API and as the database row identifier) was not always stable: a single entry could have multiple versions or localizations, and its numeric identifier id could change in cases such as duplication or import/export operations.
为了解决这一限制,Strapi 5 引入了 documentId,一个由 24 个字符组成的字母数字字符串,作为内容条目的唯一且持久的标识符,独立于其物理记录。
🌐 To address this limitation, Strapi 5 introduced documentId, a 24-character alphanumeric string, as a unique and persistent identifier for a content entry, independent of its physical records.
这个新的标识符在 Strapi 5 内部用于管理关系、发布、本地化和版本历史,因为内容条目的所有可能变体现在都被归类在单一的文档概念下。
🌐 This new identifier is used internally in Strapi 5 to manage relationships, publishing, localization, and version history, as all possible variations of a content entry are now grouped under a single document concept.
因此,从 Strapi 5 开始,许多 API 和服务依赖 documentId 而不是 id 来确保操作的一致性。一些 API 可能仍会返回 documentId 和 id 以便过渡,但强烈建议在内容查询中使用 documentId,因为 documentId 可能是未来 Strapi 版本中唯一使用的标识符。
🌐 As a result, starting with Strapi 5, many APIs and services rely on documentId instead of id to ensure consistency across operations. Some APIs may still return both documentId and id to ease the transition, but using documentId for content queries is strongly recommended, as documentId might be the only identifier used in future Strapi versions.
有关从 id 过渡到 documentId 的更多详细信息,请参阅 重大更改页面 和 从实体服务到文档服务 API 的迁移指南。
🌐 For more details on the transition from id to documentId, refer to the breaking change page and the migration guide from Entity Service to Document Service API.