This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-17
Channels
- # announcements (6)
- # beginners (117)
- # calva (22)
- # cider (7)
- # clara (56)
- # clj-kondo (8)
- # cljdoc (3)
- # cljfx (26)
- # clojure (58)
- # clojure-czech (2)
- # clojure-europe (20)
- # clojure-greece (1)
- # clojure-india (7)
- # clojure-nl (11)
- # clojure-uk (100)
- # clojurescript (48)
- # conjure (24)
- # cursive (117)
- # data-science (3)
- # datascript (5)
- # datomic (33)
- # emacs (29)
- # figwheel-main (3)
- # fulcro (12)
- # jobs (1)
- # malli (40)
- # parinfer (4)
- # pathom (1)
- # quil (2)
- # re-frame (17)
- # reagent (20)
- # reitit (1)
- # reveal (97)
- # ring (5)
- # shadow-cljs (11)
- # spacemacs (12)
- # sql (4)
- # tools-deps (18)
- # xtdb (25)
@maik.wild it seems to work okay in datascript
(defonce conn (d/conn-from-db (d/empty-db
{:employee/name {:db/unique :db.unique/identity}})))
(d/transact conn [{:employee/name "john"
:employee/admin? false}
{:employee/name "bill the admin"
:employee/admin? true}
{:employee/name "bill not admin"}])
(d/q '[:find ?e ?name
:where
[?e :employee/admin? false]
[?e :employee/name ?name]]
(d/db conn))
=> #{[1 "john"]}
Maybe it's a posh issue?
That being said, from a design perspective in datalog land, the general advice is try not to query for the absence of an attribute. So for instance the preferred way in this case might be like we did for "bill not admin"
. Instead of adding a value of :employee/admin? false
we simply didn't assert the value.Thank you for your response.
I think it could be a re-posh issue. I tried your code and it works fine. But when I run the same query using re-posh it acts very strange.
Your example returns: #{[1 "john" [2 "bill the admin]}
This workaround however seems to be doing it:
(re-posh/reg-query-sub
::user-admin
'[:find ?e ?name
:where
[?e :employee/admin? ?is-admin?]
[(= ?is-admin? false)]
[?e :employee/name ?name]])
(of course I can see the argument on the other side)
The preferred method would probably be something like this:
:employee/role :employee.role/admin
or
:employee/role :employee.role/user