Strapi API Question: can you use populate to filter non-relational fields?

There are excellent docs here about the strapi v4 populate query parameter: Understanding populate | Strapi Documentation

However, I don’t see any way listed to filter a non-relational field. My collection includes fields with text content that is very large, and the current list query is downloading all this information from the server wasting bandwidth. Is there a way to specify it to exclude the “content” top-level field from the collection when fetching?

I’ve tried the following populate parameters but none have worked:

populate: {
  content: {
    populate: false
  }
}

populate: {
  fields: [ 'title', 'updatedAt' ]
}

populate: [
  'title',
  'updatedAt'
]

This topic has been created from a Discord post (1228318554764349470) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Found it. You put the fields query parameter at root, so not under populate:

This final result did all I wanted it to do, only returning and populating the relational fields I needed:

      let query: any = {
        fields: [
          'title',
          'updatedAt',
          'scraped',
          'source'
        ],
        populate: {
          user_created_by: {
            fields: [
              'username'
            ]
          },
          published_article: {
            fields: [
              'id'
            ]
          }
        },
        filters: {
          state: state
        }
      };

Maybe it helps someone. I do wonder where the documentation for that is, I found it after digging around reading stackoverflow answers. Marking solved.

<@415915930636386304> the documentation for this is here:

nice, thanks!

ahh, so fields for normal value fields, populate for all relational fields

I thought populate was for both, as Ive seen in other apis

mostly from experience working with mongodb

that’s right, by default if you hit the endpoint with an empty query string it does basically a select * on the table, without filling the relations, than you can use fields to select attributes and populate to select relations.
you can also use filters inside the populate object to filter out the relations you want to bring, if applicable.

Yup exactly, you got it :slightly_smiling_face: