datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
unbalanced 2020-09-17T15:56:36.133900Z

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

unbalanced 2020-09-17T15:57:08.134600Z

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

unbalanced 2020-09-17T15:57:28.135100Z

The preferred method would probably be something like this:

unbalanced 2020-09-17T15:57:45.135600Z

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