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
Iโve never needed to before! (Outside of unit tests)
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])
oh cool, I don't think I've seen anyone reduce a triple clause to merely [?e] before ๐
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)