Fork me on GitHub
#meander
<
2021-01-02
>
markaddleman16:01:16

@tothda Does this do what you want?

(m/rewrite
            db
            {:items [!item ...] :labels ?labels}
            {:items [(m/cata {::item !item ::labels ?labels}) ...]}

            {::item   {:id ?id :labels [!label ...]}
             ::labels ?labels}
            {:id ?id :labels [(m/cata {::lookup-label [!label ?labels]}) ...]}

            {::item {:id ?id :labels []}}
            {:id ?id :labels []}

            {::item {:id ?id}}
            {:id ?id :labels []}

            {::lookup-label [?label (m/scan {:id ?label :name ?name})]}
            ?name)

tothda23:01:19

@markaddleman Yes! Thank you. I was not aware of (m/cata ...) , and now with this approach I was able to replace a lot of ad-hoc data manipulation code. Amazing!

clojure-spin 6