Like what we’re doing? Star us on GitHub!

Admin UI filtering not working as expected

TheDunco
4 weeks ago
7

I'm seeing an issue when filtering in the Admin UI where it's not finding a relationship with the "is in" query for certain relationships. It should find it, but it even goes so far as to display it the query is "not in" when clearly it should be there (see picture). This same filtering does work for other relationships, so I'm not sure if this is a Payload issue or an implementation issue on my part, but any insight would be appreciated!

is_not_in.png
is_in.png
  • patrikkozak
    Payload Team
    3 weeks ago

    Hi @TheDunco - In your case, in order for the

    is in

    operator to return your expected result - you would need to input the

    entire

    Stripes string value in the value input box.



    E.g.

    | Stripes | is in | Cust: (Hex/Star, IN/MM) High Leverage, (Hex) Precise Tip Geometry, (Hex) High-Performance Finish...

    Does this make sense? Let me know!

  • TheDunco
    3 weeks ago

    That does make sense I suppose, thanks. This makes me think the "is in" operation is more like an "equals" operation, though, which is slightly confusing for polymorphic (many-to-many) relationships. Are there plans to implement more of a "contains" or "includes" query? Because members of my team would like the ability to query relationships in the manner I was initially expecting the "is in" to work.



    And/or is there a method for getting this functionality with some fancy logic or something that's currently implemented that I'm not aware of?

  • patrikkozak
    Payload Team
    3 weeks ago

    Yup! In the dropdown of the filter options, we have a

    contains

    operation which will do what you were initially expecting to happen

  • TheDunco
    3 weeks ago

    I'm not seeing that option for this many-to-many "Stripes" field.

    image.png
  • patrikkozak
    Payload Team
    3 weeks ago

    Ahh - so right now - for

    array

    fields, you won't have access to the

    contains

    operation. You would use the

    is in

    operation.



    Filtering on relationships can only be done by ID. If you want to filter on nested fields, you need to use the rest api. So a

    contains

    approach wouldn't work in the UI

  • TheDunco
    3 weeks ago

    Ah, ok, that makes sense. We can get by filtering by ID. Thanks!

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More