Reputation: 88
I have a 'products' and 'categories' colleciton, then a juntion table 'producst_categories'
On products my products_categories field is a many-to-many and configured to use the juntion table as so:
But when I view the response for showing all products the products_categories is returning the products_id not the categories_id
Upvotes: 1
Views: 1761
Reputation: 1691
Your M2M relationship looks correct, so my guess is that your API request is only returning the parent item. If you want to fetch deeper/relational data (not just the ID/PK) then you'll need to use the fields
parameter:
It uses dot-notation for the depth — with wildcards (*
) for all fields, or exact field names. For example:
?fields=*.*.*
// OR...
?fields=products.categories.name
https://docs.directus.io/api/query/fields.html
Upvotes: 2