Fork me on GitHub
#meander
<
2021-09-02
>
jgdavey13:09:14

I’m attempted to do something like a “left” join, but there’s definitely a couple of issues with my attempt, as you can see. What’s the right way to think of this?

jgdavey16:09:23

If I’m understanding correctly, this maybe pattern helps in the case of a nil, but not when a key is not present in the map. Also, I’m struggling with m/scan or if what I really want is m/cata. Any intuition on when to use those?

jgdavey16:09:31

It looks like this is what I’m looking for:

(m/rewrite data
    {:name ?name
     :categories [{:category-name !cat-name
                   :id !cat-id} ...]
     :sub-categories ?subs}

    {:name ?name
     :categories [{:name !cat-name
                   :sub-categories (m/app get ?subs !cat-id)}
                  ...]})