Fork me on GitHub
#datomic
<
2017-03-16
>
uwo21:03:44

I have a set of eids I know I want to exclude from my query results. what’s a good way to achieve this. (here’s a pseudo-code query I know doesn’t work):

uwo21:03:11

(just as clarification, ?gid is a uuid and ?exluded-bills is a set of entity ids)

favila21:03:17

'[:find [?b ...]
  :in $ ?gid [?excluded-invoice-group-id ...]
  :where
  [?g :invoice-group/id ?gid]
  (not [(= ?excluded-invoice-group-id ?g)])
  [?g :invoice-group/bills ?b]]

favila21:03:34

But it'd be even better probably to just test set membership directly

favila21:03:07

'[:find [?b ...]
  :in $ ?gid ?excluded-invoice-group-id-set
  :where
  [?g :invoice-group/id ?gid]
  (not [(contains? ?excluded-invoice-group-id-set ?g)])
  [?g :invoice-group/bills ?b]]

uwo21:03:01

ahh, yeah. that is simpler.

favila21:03:10

probably faster also