How does one handle the following use case: I have a complicated report that allows the user to filter/narrow the results in a multitude of different ways. Let's say for example it's an order report. The user might want to view only the orders placed between yesterday and today, or they might only include orders placed by a particular customer, etc...
Some of these query inputs have obvious defaults (eg the default date range can just be "orders placed today"), but others do not (the default customer should be all customers).
How does one handle the optionality of the latter case?
Here is a contrived example that demonstrates the problem:
(d/q '[:find ?p
:in $ ?name
:where [?p :product/name ?name]]
This is fine if the user actually provides the name of a product to filter by, but if they don't, I'd like to default to returning all products. I could easily just create two separate queries, one where the product name is an input, and the other where it isn't, but there would then be a combinatorial explosion of queries to cover all input possibilities.
nil in as an input results in an exception.
Perhaps the best way to solve this is not within the query at all, and I should instead query for the lazy seq of all entities, and then just use Clojure's
filter to trim that list down?