@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)
@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!