This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-26
Channels
- # announcements (1)
- # atom-editor (7)
- # babashka (9)
- # beginners (46)
- # cider (1)
- # circleci (2)
- # clj-on-windows (1)
- # cljdoc (5)
- # cljsrn (2)
- # clojure (25)
- # clojure-austin (8)
- # clojure-brasil (4)
- # clojure-europe (52)
- # clojure-nl (1)
- # clojure-norway (162)
- # clojure-uk (2)
- # cursive (3)
- # datalevin (134)
- # datomic (16)
- # defnpodcast (8)
- # graphql (9)
- # honeysql (5)
- # hoplon (26)
- # hyperfiddle (18)
- # introduce-yourself (1)
- # lsp (4)
- # malli (19)
- # nbb (16)
- # nrepl (1)
- # practicalli (3)
- # releases (3)
- # shadow-cljs (36)
- # tools-deps (7)
- # vim (2)
- # xtdb (9)
Hi, can’t find it the docs, but is there an example query that I can send over http that returns records in the last x days? I have something like the following, but stuck on how to replace #inst "2023-04-26T00:00:00.000-07:00"
with current time. any tips on simplifying the query are highly appreciated!
{:query {
:find [(pull ?e [*]) start-time ref-ms diff-ms],
:where
[[?e :xt/id]
[?e :user "user:1"]
[(get-start-valid-time ?e) start-time]
[(inst-ms start-time) start-ms]
[(inst-ms #inst "2023-04-26T00:00:00.000-07:00") ref-ms]
[(- start-ms ref-ms) diff-ms]
[(> diff-ms 86400000)]
]
:order-by [[start-time :desc]]
}}
you could pass it in as an 'in-arg' - would this work for you?
{:query '{:find [(pull ?e [*]) start-time],
:in [after-ms]
:where [[?e :xt/id]
[?e :user "user:1"]
[(get-start-valid-time ?e) start-time]
[(inst-ms start-time) start-ms]
[(> start-ms after-ms)]]
:order-by [[start-time :desc]]}
:in-args [(- (System/currentTimeMillis) 86400000)]}
this binds the argument to after-ms
during the query, then checks the start-ms is after that
alternatively, if you have one :xt/id
in hand (i.e. you're only looking for one entity, and you know its id), you could try the https://docs.xtdb.com/language-reference/datalog-queries/#history-api API?
Hi @U050V1N74 thanks for the reply! is what you pasted clojure? is there a way to pass in-arg in a http request? I couldn’t find an example in the docs
I tried adding [(System/currentTimeMillis) now]
in where
, and got {"type":"exception","class":"