I have a datastructure that's a combination of maps and vectors, with various amounts of nesting:
[{:user "matt"
:docs [{:fulltext "the text"
:url "<http://www.google.com|www.google.com>"
:fragments []}
;; more docs
]}
;; more maps
]
I want to update the data structure like so
[{:user "matt"
:docs [{:fulltext "the text"
:url "<http://www.google.com|www.google.com>"
:fragments [{:date "2018" :text "the "}
{:date "2017" :text "text"}]}
;; more docs
]}
;; more maps
]
I want to do: "select the map with the key-value pair :user
and "matt"
, then in the :doc
vector, select the map with the kv pair :fulltext
and "the text"
and conj these two maps"I skimmed the Navigators docs, and couldn't find "select the map containing the kv-pair." I suspect that I'm trying to do something not idiomatic. In theory, I could make this data structure entirely out of nested maps--then this would be trivial--but i don't know if i can guarantee that a map will have a unique key.
@mfm looks like this:
(defn map-with-kv [k v]
(path ALL #(= v (get % k))))
(setval
[(map-with-kv :user "matt")
:docs
(map-with-kv :fulltext "the text")
:fragments
END
]
[{:date "2018" :text "the "}
{:date "2017" :text "text"}]
data)
ah, thank you @nathanmarz!