Search code examples
mongoosestrapi

Filter on relation property


I have a content with a simple relation (using MongoDB, btw):

Professional:
  - name
  - categories (has many)
Categories:
  - name
  - slug

A professional can have up to many categories as he wants.

I want to filter professionals that have certain categories, like:

Professionals that have category 'foo'

So far I've tried this:

/professionals?categories.slug=foo
/professionals?categories.name=foo
/professionals?categories._id=(a id)

None of these returns the proper values. Is there any way to do this manually through mongoose?


Solution

  • I just tested with the last version of Strapi and it works well.

    Your 3 requests worked.

    Here is a screen record of what I did - https://www.loom.com/share/e762efba49bc41f290ecf75fa983159e

    Let me know if I messed something.