Skip to main content

在 Strapi 5 中,按 id 排序不再可能按时间顺序排序

¥Sorting by id is no longer possible to sort by chronological order in Strapi 5

在 Strapi 5 中,由于 documents 使用 uuid,因此按 id 排序以按时间顺序排序不再可能。

¥In Strapi 5, sorting by id to sort by chronological order is no longer possible since documents use an uuid.

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的其他说明。

¥This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

 Is this breaking change affecting plugins?Yes
 Is this breaking change automatically handled by a codemod?Yes
(see entity-service-document-service )

重大更改描述

¥Breaking change description

在 Strapi v4 中

¥In Strapi v4

在 Strapi v4 中,使用实体服务 API,你可以执行以下操作按时间顺序对条目进行排序:

¥In Strapi v4, using the Entity Service API, you could do the following to sort entries by chronological order:

strapi.entityService.findMany('api::article.article', {
sort: 'id',
});

在 Strapi 5 中

¥In Strapi 5

在 Strapi 5 中,使用 文档服务 API 按时间顺序对文档进行排序,使用 createdAt 字段:

¥In Strapi 5, use the Document Service API to sort documents by chronological order, use the createdAt field:

strapi.documentService.findMany('api::article.article', {
sort: 'createdAt',
});

迁移

¥Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

¥This section regroups useful notes and procedures about the introduced breaking change.

手动程序

¥Manual procedure

不需要手动程序,因为这将由代码修改处理。

¥No manual procedure should be required as this will be handled by a codemod.