Fork me on GitHub
#datomic
<
2016-06-16
>
grav10:06:36

Can I check if all entities in a list have the same value for an attribute with a single query?

bahulneel13:06:50

@grav you can look entities the do not have the same value as any other entity

bahulneel13:06:59

[:find ?e :where [_ :attr ?v] (not-join [?e] [?e :attr ?v])]

bahulneel13:06:04

also, there's a mistake, the not-join should include ?v

bahulneel13:06:23

also not sure the query is safe as there is a free variable in negated part that isn't in the positive part

bahulneel13:06:32

@grav this would be better [:find (count-distinct ?v) :where [_ :attr ?v]]