I’ll throw out another solution just in case anyone is interested.
(m/rewrite db
{:items [{:id !ids :labels (m/or [!labels ..!n]
(m/let [!n 0]))} ..!m]
:labels ?labels}
{:items
[{:id !ids :labels [(m/cata [!labels ?labels]) ..!n]} ..!m]}
[?label (m/scan {:id ?label :name ?name})]
?name)
Thank you!
Would be useful to post this to the original stackoverflow question too.