在 Strapi 5 中,按 id 排序不再可能按照时间顺序排序
🌐 Sorting by id is no longer possible to sort by chronological order in Strapi 5
在 Strapi 5 中,由于文档使用 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.
重大变更描述
🌐 Breaking change description
在 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 中
在 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.