Fork me on GitHub

Hey all, is it possible to parameterise the attributes in a query? I have found examples of how to parameterise the values using :args but this approach apparently does not work with attributes.


Hey @U09UV3WP6 - I'm afraid Crux doesn't generally support dynamic attributes in queries using args. That said, so long as it's not directly dependent on user input (to avoid injection attacks) you can dynamically generate the query itself using Clojure's standard functions - the query itself is a data structure. eg rather than '{:find [?e] :where [?e :attr "attr"]} you can move the quote inside the data structure, quoting everything except the attribute:

(let [attr ...] 
  {:find '[?e] :where ['?e attr "attr"]}
which may be sufficient for your use-case?


Got it, I think that will work nicely.


Yeah that worked great, thanks.


great 🙂 you're welcome