How to filter results when using keyset pagination?
After a lot of trial and error, I managed to get the next page for the keyset pagination in my project by using something like
This works perfectly fine, however I also have filters the user could apply to the items list. I got one solution working, however I'm not sure if it's the "proper" way to do it. I'm wondering if there would be a more cleaner solution to do it?
My current solution is based on the small Filters guide in the Ash Documentation:
3 Replies
Hey there! Arguments to the read action is one way to do it, but you can also provide a filtered query as a "starting point". For instance, if you just had. a read action with key set pagination available called
:read
Ah, that seems pretty nice. Thanks! Still a newbie in Elixir & Ash world, so gotta start keeping this kind of query approach in mind more 😄
It all depends on how you want to design things, but this approach makes sense when you just want to do things like allow arbitrary filtering from a UI like this without having to add a bunch of structure to your resources 🙂