Last active
June 23, 2020 13:24
-
-
Save aviflax/dfb111526667aaeb5baac4b79ccde0df to your computer and use it in GitHub Desktop.
Using Specter to modify deeply-nested values in a DaD DB. Start the REPL with `clj -A:repl:dad:specter`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; These aliased can/should be added to the same section in ~/.clojure/deps.edn | |
; They can then be “activated” by starting the REPL with: clj -A:repl:dad:specter | |
{:aliases | |
{:repl {:jvm-opts ["-XX:-OmitStackTraceInFastThrow" | |
"--illegal-access=deny" | |
"-Dclojure.server.repl={:port,0,:accept,clojure.core.server/repl}"] | |
:main-opts ["-e" "(.getLocalPort,(get-in,@#'clojure.core.server/servers,[\"repl\",:socket]))" | |
"-r"]} | |
;; *** LIBRARIES *** | |
:dad {:extra-deps {dad {:git/url "https://github.com/FundingCircle/dad" | |
:sha "865aa9711b3ff23940eaeb08cb12c41abf9fb508"}}} | |
:specter {:extra-deps {com.rpl/specter {:mvn/version "1.1.3"}}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[dad.db :as db]) | |
(use 'com.rpl.specter) | |
(def db (db/read "db")) | |
(select [:technologies MAP-VALS "recommendations" ALL] db) | |
(->> db | |
(transform [:technologies MAP-VALS "recommendations" ALL] | |
#(-> (assoc % "proposed" {"by" (% "proposed-by")}) | |
(dissoc "issued-by" "issued-on" "proposed-by"))) | |
(db/overwrite)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discover which technologies have recommendations that have been ratified:
I haven’t yet figured out how to do this with Specter.