Fork me on GitHub
#datascript
<
2020-09-17
>
Lone Ranger15:09:36

@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.

Maik Wild06:09:27

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]])

Lone Ranger15:09:08

(of course I can see the argument on the other side)

Lone Ranger15:09:28

The preferred method would probably be something like this:

Lone Ranger15:09:45

:employee/role :employee.role/admin or :employee/role :employee.role/user