Skip to main content

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

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

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

In Strapi v4

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

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' });

In 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

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

In Strapi v4

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

In Strapi 5

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