Conditional filters in read actions
Hi there, I'm back with another quesion that i couldnt find an answer to - sorry if i missed something.
I have a resource with a list of form submissions, where i have a read action to get all form submission of a specific form id, with the form_id as an argument. that works fine.
Now i also want to add the possibility to get all records submitted after a specific date, which also works this way:
Now, the
I am aware that i could just split this up into 2 different actions, but that would require duplicating things like the default sort order and filtering by form id.
Thanks!
I have a resource with a list of form submissions, where i have a read action to get all form submission of a specific form id, with the form_id as an argument. that works fine.
Now i also want to add the possibility to get all records submitted after a specific date, which also works this way:
filter expr(submission_time >= ^arg(:min_submission_time)).Now, the
:min_submission_time argument is optional - i want to be able to use the same action for getting both all as well as the filtered submissions. Is there a way to have a conditional in the action to only apply the :min_submission_time filter if the argument is not nil? As far as I know the action code is evaluated at compile time, so i cant use a normal elixir if/else.I am aware that i could just split this up into 2 different actions, but that would require duplicating things like the default sort order and filtering by form id.
Thanks!
