Fork me on GitHub
#meander
<
2021-01-01
>
tothda19:01:06

Hi! I'm trying to join two set of maps together. Basically the problem is exactly what is described in this SO question: https://stackoverflow.com/questions/63520565/a-declarative-way-of-reshaping-joining-flattening-data-in-nested-maps Is there a solution for it with meander? Thanks! I copy the relevant part here.

;; my input data
(def db {:items  [{:id 1 :labels [1 2 3]}
                  {:id 2 :labels [2]}
                  {:id 3 :labels []}
                  {:id 4 :labels nil}
                  {:id 5 }]
         :labels [{:id 1 :name "one"}
                  {:id 2 :name "two"}
                  {:id 3 :name "three"}
                  {:id 4 :name "four"}]})

;; what to do here
(defn flatten-labels [d]
  ???)

;; so that I get this
(flatten-labels db)
;; =>
;; {:items
;; [{:id 1 :labels ["one" "two" "three"]}
;;  {:id 2 :labels ["two"]}
;;  {:id 3 :labels []}
;;  {:id 4 :labels []}
;;  {:id 5 :labels []}]}