This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-03
Channels
- # announcements (5)
- # babashka (7)
- # beginners (119)
- # biff (4)
- # cider (7)
- # clj-kondo (26)
- # cljfx (3)
- # cljs-dev (2)
- # clojure (28)
- # clojure-austin (18)
- # clojure-europe (9)
- # clojure-france (6)
- # clojure-norway (4)
- # clojure-uk (3)
- # clojurescript (6)
- # community-development (1)
- # core-async (4)
- # cursive (9)
- # data-science (12)
- # datomic (13)
- # duct (18)
- # emacs (15)
- # etaoin (5)
- # events (13)
- # honeysql (46)
- # hyperfiddle (9)
- # jackdaw (5)
- # jobs (13)
- # keechma (4)
- # lsp (37)
- # malli (32)
- # nbb (14)
- # off-topic (10)
- # other-languages (2)
- # polylith (4)
- # programming-beginners (3)
- # reagent (27)
- # reitit (1)
- # shadow-cljs (32)
- # sql (11)
- # tools-build (5)
- # tools-deps (3)
- # vim (14)
- # xtdb (11)
I want to filter the result by the fact if the key do not exist or it's value (date) is lower then the provided arg. So in pseudo code it would look like this:
[:find ?fizz
:in $ ?my-date
:where
[?fizz :fizz/buzz ?buzz]
(or (missing? $ ?fizz :fizz/date)
[(< ?now-date [?fizz :fizz/date])])]
Is that possible in the query?or statement and join-or are a bit funky in how they work, and i haven't been very successful in using them
I think you want something like this:
[:find ?fizz
:in $ ?my-date
:where
[?fizz :fizz/buzz ?buzz]
(or-join [?fizz]
[(missing? $ ?fizz :fizz/date)]
[(< ?my-date [?fizz :fizz/date])])]
@U0394DH0S3W Yeah that's what I meant, but the case is that this code do not work in datomic as this line gives me message:
[(< ?my-date [?fizz :fizz/date])]
Unable to resolve symbol: ?fizz in this context
While if I remove this one line it all works
https://docs.datomic.com/on-prem/query/query.html#predicate-expressions there is an example of using preds in a query
i'm not sure [?fizz :fizz/date]
is valid. does anyone have examples of this syntax being used in queries?
[?fizz :fizz/date]
is valid in a where, but I don’t think it does what you want. Sorry I didn’t pay too much attention to that when adding the or-join
.
[?fizz :fizz/date]
unifies ?fizz
to entities that have a :fizz/date
attribute but it doesn’t extract the value of the attribute.
I think this is what you want:
[:find ?fizz
:in $ ?my-date
:where
[?fizz :fizz/buzz ?buzz]
(or-join [?fizz]
[(missing? $ ?fizz :fizz/date)]
(and [?fizz :fizz/date ?fizz-date]
[(< ?my-date ?fizz-date))])]