I'm fairly new to Clojure so apologies if this is a stupid question, but I have a map which is fairly complex (it contains nested maps, vectors etc.). Before I put it into my database, I essentially want to dissoc a bunch of things I don't need to save write speed (in this case it's a significant performance improvement). I'd like to filter out all the bits I don't need by making a schema of some sort which could be used to remove anything unnecessary. Here's an example of the sort of thing I'm trying to achieve (weird example, apologies!):
(def my-book
{:intro {:one-liners [{:line "wowza" :rating 7}
{:line "cool!" :rating 4}]}
:how-many-lines 10
:rubbish-one-liners [{:line "bongo" :rating 1}
{:line "foo" :rating 2}]
:other-info {:author {:name "me" :age 24}}})
(def my-schema
[{:intro [{:one-liners {:values [:line :rating]}}
{:values [:how-many-lines]}
{:rubbish-one-liners {:values [:line]}}
{:other-info {:author {:values [:name]}}}]}])
;;expected output when filtering via the schema:
(def my-output
{:intro {:one-liners [{:line "wowza" :rating 7}
{:line "cool!" :rating 4}]}
:how-many-lines 10
:rubbish-one-liners [{:line "bongo"}
{:line "foo"}]
:other-info {:author {:name "me"}}})
I'm not really sure if that schema is at all the best way to go about it/structure, and once I do have a schema how to actually go about it given there seems to be a lot of different data structures involved - so I guess my question is, how would you advise I go about walking through whatever structure I have and removing keys based on a schema? :) thanks!