Skip to main content

用于权限提供者实例的 getWhere() 方法已被移除

🌐 The getWhere() method for permission provider instances has been removed

在 Strapi 5 中,权限提供者实例的 getWhere() 方法已被移除,用户应先获取提供者的值,然后进行过滤。

🌐 In Strapi 5, the getWhere() method for permission provider instances has been removed, and users should first get the provider values, then filter them.

此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 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?No

重大变更描述

🌐 Breaking change description

在 Strapi v4 中

提供一个浏览器名称来代替默认名称,XX1 表示停止打开浏览器。

🌐 Provider instances (action provider, condition provider, etc…) are built using a provider factory.

这些提供商有一个 getWhere 方法,允许你查询符合特定条件的提供商项目并返回它们。

🌐 Those providers have a getWhere method allowing you to query provider’s items that match certain conditions and return them.

查询是一个对象,其中键和值与提供程序条目匹配:

🌐 The query was an object where keys and values were matched with the provider entries:

const values = provider.getWhere({ foo: 42, bar: 'baz' });

在 Strapi 5 中

你需要采用更传统的方法,首先获取提供商值,然后使用自定义谓词对其进行过滤:

🌐 You need to adopt a more conventional approach by first getting the provider values, then filtering them using a custom predicate:

const values = provider.values().filter(value => value.foo === 42 && value.bar === 'baz');

迁移

🌐 Migration


手动操作

🌐 Manual procedure

如果使用 getWhere() 方法,用户需要手动更新他们的代码,可以参考以下示例:

🌐 Users need to manually update their code if using the getWhere() method, using the following example as a guide:

在 Strapi v4 中

const values = provider.getWhere({ foo: 42, bar: 'baz' });

在 Strapi 5 中

const values = provider.values().filter(
value => value.foo === 42 && value.bar === 'baz'
);