This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-08
Channels
- # announcements (14)
- # babashka (12)
- # beginners (140)
- # calva (2)
- # cider (22)
- # clj-commons (14)
- # clj-kondo (49)
- # cljdoc (34)
- # clojure (92)
- # clojure-europe (41)
- # clojure-france (2)
- # clojure-new-zealand (2)
- # clojure-nl (2)
- # clojure-norway (60)
- # clojure-uk (17)
- # clojured (2)
- # clojurescript (7)
- # community-development (3)
- # conjure (2)
- # cryogen (13)
- # cursive (4)
- # data-oriented-programming (2)
- # datahike (5)
- # datomic (12)
- # defnpodcast (10)
- # events (2)
- # fulcro (20)
- # gratitude (3)
- # honeysql (4)
- # introduce-yourself (3)
- # jobs (10)
- # lsp (58)
- # malli (12)
- # missionary (19)
- # off-topic (8)
- # pathom (18)
- # podcasts-discuss (1)
- # polylith (41)
- # releases (1)
- # remote-jobs (3)
- # shadow-cljs (52)
- # spacemacs (1)
- # sql (37)
- # xtdb (19)
I am trying to do a outer join and I cannot find a way to do it. I have :tracking/invoice which is a ref to an invoice. I would like to pull all fields from Invoice and tracking. But it might be that an invoice does not have tracking. I could do it with two separate queries. First get rhe invoice and pull all its fields. Then pull the tracking by searching via tracking/invoice and pull there. But I want to operate in thousands of invoices, so I think two queries is a bad idea. I found: lookup-ref? Perhaps this does what I need.. But I cannot find docs for it. Any ideas?
(def xero-orders '[:find [?id ?t (pull ?t [*]) (pull ?id [*]) ] :in $ ?inv-no ; ?xxx :where [?id :xero/invoice-number ?inv-no] [?t :tracking/invoice ?id] ;[(get-else $ ?id :tracking/invoice ::no-val) ?t] ;[(?xxx $ ?e :tracking/invoice) ?t] ;[?t :tracking/tag ?tag] ])
so this query works, but it only gives me data, when :tracking/invoice refers to an invoice. In case there is no tracking yet, then I get nil. In this case I still need the invoice data.
Maybe I don't quite understand your case... But this looks like a case for a https://docs.datomic.com/on-prem/query/pull.html#reverse-lookup
(d/pull db ['* {:tracking/_invoice ['*]}] [:xero/invoice-number 42])
If invoice 42 has no tracking. :tracking/_invoice
is nil
.