Closed dbushenko closed 7 years ago
I'm doing like this:
(defn init-db [ db ] (c/with-write-transaction [db tx] (when-not (c/get-at tx [:counters :user-id]) (c/assoc-at tx [:counters :user-id] 1))))
This is for the one-time DB initialization. As you see, if the DB was already initialized, the body of the when-not will not be evaluated, nothing is written to DB. This leads to NullPointerException clojure.lang.RT.longCast (RT.java:1259)
I'm doing like this:
(defn init-db [ db ] (c/with-write-transaction [db tx] (when-not (c/get-at tx [:counters :user-id]) (c/assoc-at tx [:counters :user-id] 1))))
This is for the one-time DB initialization. As you see, if the DB was already initialized, the body of the when-not will not be evaluated, nothing is written to DB. This leads to NullPointerException clojure.lang.RT.longCast (RT.java:1259)