   (let [editing (querydb [:editing])]
     (updatedb [:editing] (conj editing pos))))
 
-(defn update_field [pos key value]
-  (let [item (assoc (querydb [:data pos]) key value)]
-    (set! db (assoc-in db [:data pos] item))))
-
 (defn save [item pos]
   "Save item to db :data into position"
   (let [doc (assoc item "mtime" (str (new js/Date)))
         data (querydb [:data])]
     (updatedb [:data] (assoc data pos doc))
     (println "Saved!" (get doc "path"))))
+
+(defn update_field [pos key value]
+  (let [prev (querydb [:data pos])
+        item (assoc prev key value)]
+    (println "Editing: " pos key value)
+    (save item pos)))
 
 (defn close
   [pos]

(defn reporender
  "Render repository trees"
  []
  (let [tree (get (querydb [:data]) "tree")]
    (map-indexed node tree)))




;; Data

(def db {:data (get REPO "tree")
         :start 0
         :editing #{}})

