This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-31
Channels
- # announcements (1)
- # aws (4)
- # babashka (40)
- # beginners (89)
- # calva (13)
- # cider (3)
- # clj-kondo (36)
- # cljdoc (16)
- # clojure (74)
- # clojure-boston (1)
- # clojure-dev (7)
- # clojure-europe (30)
- # clojure-new-zealand (1)
- # clojure-nl (17)
- # clojure-uk (5)
- # clojurescript (16)
- # core-async (9)
- # cursive (16)
- # datahike (3)
- # datalog (6)
- # datascript (7)
- # datomic (15)
- # emacs (38)
- # events (2)
- # figwheel-main (3)
- # fulcro (6)
- # google-cloud (18)
- # graalvm (6)
- # gratitude (1)
- # honeysql (1)
- # introduce-yourself (1)
- # jobs (1)
- # leiningen (5)
- # lsp (6)
- # malli (11)
- # meander (2)
- # off-topic (4)
- # re-frame (6)
- # reitit (8)
- # releases (2)
- # remote-jobs (3)
- # reveal (4)
- # shadow-cljs (200)
- # sql (8)
- # tools-deps (16)
what’s the best way to find entities without db.type/ref
relationships? in a graph these could be called orphan nodes.
Thinking of Datomic:
:find ?e :where [?e ?a ?v] [?a :db/ident] (not [?o ?r ?e] [?r :db/ident])
The :db/ident
statements are because unbound patterns make Datomic nervous. (I’m not sure if it's needed in the not
expression)
XT doesn't support wildcard attribute vars, which is needed for a single not
to be sufficient, so you'd either need a not
per attribute (e.g. generating verbose queries), or you can define orphan?
as a custom function that executes an inner query per attribute: https://gist.github.com/refset/25d8ae03c69993831c9c23cf7e12a537
This is where it gets tricky between databases.
For instance, Asami has several options, but for this query it could just use:
:find ?e :where [?e] (not [_ _ ?e])