#Rest API filtering

1 messages · Page 1 of 1 (latest)

worldly nebula
#

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

https://domain.com/api/posts?where[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 - https://payloadcms.com/docs/queries/overview#rest-queries

What am I doing wrong?

Payload CMS

Payload is a headless CMS and application framework built with TypeScript, Node.js, React and MongoDB

brazen lodge
#

Hey, I see that you are using hasMany: true, so you should try with something like ?where[tags.name][equals]=tagname where name is a property from Tags collection