Rest API filtering

default discord avatar
.kilosierra11 months ago

My posts collections includes tags as follows

      name: 'tags',
      type: 'relationship',
      relationTo: 'tags',
      hasMany: true,

I want to be able to filter the response by tag name. I also want to place a limit of 6 so I don't break my pagination, etc.

Given a tag of "Guides", shouldn't I be able to filter my posts using[tags][equals]=Guides&limit=6&page=1

The above url params don't work. I've attached a screenshot of the api response.

I'm using this url based on my interpretation of the following documentation -

What am I doing wrong?

  • default discord avatar
    svn__11 months ago

    Hey, I see that you are using

    hasMany: true

    , so you should try with something like


    where name is a property from Tags collection

    You can find more details in this section:

    , and more specifically under "Has Many - Polymorphic"

  • default discord avatar
    .kilosierra11 months ago

    That worked perfectly. Thanks

Star on GitHub


Chat on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.