How can I filter within collection-link? e.g. filter[collection.field]=value

#1

I am trying to query with a relation on it. For example:
…localhost/cockpit-master/api/collections/get/tags?token=4f317a928d33bce6851dbfff9287ca&filter[tag_type.title]=Category

But it don’t work:

But both of these works:

  • …localhost/cockpit-master/api/collections/get/tag_types?token=4f317a928d33bce6851dbfff9287ca&filter[title]=Category
  • …localhost/cockpit-master/api/collections/get/tags?token=4f317a928d33bce6851dbfff9287ca&filter[level]=0

Here are some screenshots to help understand my setup:

  • …imgur.com/ydpJNef
  • …imgur.com/unNEIhP
  • …imgur.com/QQDBfsN
  • …imgur.com/WVo7InB
  • …imgur.com/nMD9MD4
    (for some reason I cannot add more than 2 links on my post, so just add https:// to the links above)

Any idea why is not working? or what am I doing wrong?

Thanks!

0 Likes

#2

if you are using the shipped sqlite backend (and no external DB like mongo) you are not able to filter by a collection link. The SQLite implementation uses https://github.com/agentejo/mongo-lite which is not able to filter by field subsets

Filtering on a collectionlink

0 Likes

#3

Hi @serjoscha87 I simply downloaded the .zip file and ran. How can I upgrade for mongodb?

0 Likes

#4

Wait I am actually a bit confused. Because I just tried in the demo this: https://demo-api.directus.app/_/items/sales?filter[member.first_name][eq]=Osborn at it worked!

The only setup I needed to do to the default demo was to give Read permissions to the Public user group (which I also done on my local)

0 Likes

#5

Now I am actually confused - gonna take a look into this later for the satisfaction of my own curiosity. Thanks for the hint.

0 Likes