"filters" and "populate" cannot be used together 🤔

System Information
  • Strapi Version: 4.14.0
  • Operating System:
  • Database: PostgreSql
  • Node Version: 16.20.2
  • NPM Version: 8.19.4

Hello guys,

Somehow “filters” and “populate” cannot be used together for me, the following example:

:white_check_mark: Fetch all data - It works!

    res = await strapi.db.query('api::key.key').findMany({
      populate: true
     });

:white_check_mark: Search for a keyword - It works!

    res = await strapi.db.query('api::key.key').findMany({
      filters: {
        uid: {
          $contains: keyword    // 'ABC...'
        }
      }
     });

:x: But when I bring the two together it doesn’t work anymore:

    res = await strapi.db.query('api::key.key').findMany({
      populate: true,
      filters: {
        uid: {
          $contains: keyword
        }
      }
     });

The error message says that the “uid” column doesn’t exist?! :thinking:

Who can give me a tip, where is my mistake?

Thanks in advance!

User where: {} condition instead of filters:{} and also go through the below strapi docs for better clarification on using Query API

1 Like

Thank you for your quick reply! My problem is now solved, I have learned something again! :+1:
I wish you a nice day! :beer:

1 Like