clara

Shawn 2022-06-19T14:01:50.753069Z

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}

ethanc 2022-06-19T16:59:40.678909Z

Queries in Clara only support equality matches on provided parameters.

Shawn 2022-06-19T19:02:00.547249Z

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?

ethanc 2022-06-19T19:04:44.063489Z

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
Shawn 2022-06-19T19:09:38.456919Z

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

ethanc 2022-06-19T22:01:25.649559Z

yes