Fork me on GitHub
#clara
<
2022-06-19
>
Shawn14:06:50

Hi all, just getting started with Clara and hit a point of confusion. I'd like to query records that fall within a given date range. I'm trying define a query with ?start and ?end parameters, but from what I've tried, mk-session fails out saying that those variables are unbound. Any tips?

(defrecord Foo [date])

(defquery get-foos-in-date-range
  [?start ?end]
  [?foos <- (acc/all) :from [Foo (date-in-range? date ?start ?end)]])

(mk-session) ;; Exception: Unbound variables #{:?start :?end}

ethanc16:06:40

Queries in Clara only support equality matches on provided parameters.

Shawn19:06:00

Ah, so this isn't possible with a query? I'm guessing then I should just query all Foos and do a filter outside the query?

ethanc19:06:44

That, or insert a fact that would represent the values needed, join it to the foos and insert only the matched foos as another fact

💯 1
Shawn19:06:38

Hm, like a filter-foo rule that could have that predicate (and possibly others) that inserts a FilteredFoo fact?