Fork me on GitHub

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:

👍 1

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

💯 2

oh cool, I don't think I've seen anyone reduce a triple clause to merely [?e] before 🙂


I’ve never needed to before! (Outside of unit tests)

😄 1