Fork me on GitHub
#crux
<
2020-03-22
>
Akshay C. Gollapalli01:03:47

I think this might be a tick issue instead of a crux issue, but I can't seem to get this query to work properly: (crux/q (crux/db db) '{:find [e time] :where [[e :log/time time] [(tick/<= time (tick/- (tick/now) (tick/new-duration 2 :minutes)))]]}) Error: class clojure.lang.PersistentList cannot be cast to class java.time.Instant Does Crux treat things like "time" in the query above as lists before running them through predicates? Or is there something simple I missed? Document being queried: {:crux.db/id :demo-app/log, :log/event "app-stopped-successfully", :log/time #time/instant "2020-03-22T01:03:41.569599Z", :log/frequency #time/duration "PT1H"}

refset19:03:15

Hi @US65YEL1M it looks like you're trying to use Clojure directly inside of Crux Datalog, which isn't supported in the way you're trying to do here. Basically, you need to create a separate predicate function which you can then reference using a fully qualified name - see this issue which has a couple of examples that will help: https://github.com/juxt/crux/issues/732

Akshay C. Gollapalli02:03:53

Thanks, defining my function (f) elsewhere and then using syntax quoting did the trick. (crux/q (crux/db db) {:find '[e time] :where ['[e :log/time time] [(f ~'time)]]})`