This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-23
Channels
- # ai (1)
- # aleph (1)
- # announcements (7)
- # babashka (87)
- # beginners (34)
- # biff (9)
- # clerk (4)
- # clojars (37)
- # clojure (142)
- # clojure-art (12)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (4)
- # clojure-uk (2)
- # clr (5)
- # conjure (1)
- # data-science (1)
- # datahike (7)
- # datalevin (6)
- # datomic (13)
- # events (1)
- # fulcro (1)
- # graalvm (5)
- # gratitude (1)
- # honeysql (4)
- # hyperfiddle (122)
- # malli (26)
- # nbb (2)
- # off-topic (16)
- # portal (93)
- # practicalli (1)
- # re-frame (1)
- # reitit (15)
- # releases (3)
- # remote-jobs (1)
- # shadow-cljs (5)
- # tools-deps (6)
- # xtdb (4)
In Datalog queries, is there a way to specify that all/some/none of a related set of entities meet a criteria? e.g. given order
s with multiple shipment
s, can I write a query that finds orders where all the associated shipments have a status of :shipped
?
Try something like this:
'{:find [[order-id (count shipped-id) (count any-shippped-id)]
:where [[order-id :order/id]
[shipped-id :shipment/order-id order-id]
[shipped-id :shipment/status :shipped]
[any-shipped-id :shipment/order-id order-id]]}
Then you can filter resulting tuples where count doesn't match. You can even use cond/if as a forth argument within find.OK that makes sense! Presumably if I wanted to add a pull
query to the orders, it might make sense to run this query first, filter to get matching IDs, then xt/pull-many
those IDs? Otherwise I'd be fetching a lot of data which would then be discarded?
Yeah, getting ids and then pulling data by them will be the best way to go. Since you're querying against the "immutable value" of db there is no need to make overly complicated query to make sure you get all the data in one pass.