Hi all,
I have a script that updates data in a MongoDB database using the monger library. All updates are performed when I open a repl and copy/paste the code, but I can't get it to work with lein run
.
The relevant code:
(ns covid-data-management.core
(:require [oz.core :as oz]
[monger.core :as mg]
[monger.collection :as mc]))
(defonce db (mg/get-db (mg/connect) "covid19"))
(def coll "surveys")
(defn update-symptoms []
(println "In the update-symptoms definitions")
(map (fn [x]
(mc/update db coll {} {"$set" {:symptoms ["symptom1" "symptom2"]}}))))
(defn main [& args]
(update-symptoms))
Copy/pasting the code in the REPL does exactly what it should do: set the new symptoms. When running with lein run
, the string "In the update-symptoms definitions" is printed to the console, but the database itself is not changed.
I suspect that it has to do with the no-side-effects and lazy features of clojure but haven't found the solution yet. Any help appreciated!
Thank you,
j.