       (-> blog
           (transform-using to-db-transform)
           (insert-and-return dbo))
-      (error "Refusing to create" user blog dbo))))
+      (error "Db object deleted or not own. Refusing to create" user blog dbo))))
 
 (defn get [id]
   (from-db-to-user (find-dbo id)))

(def to-db-transform
  {:drop [:id]
   :transform {:distance parse-distance
               :time parse-duration}
   :validation [:user #(-> % :draft nil? not)]})

(defn find-dbo [id]

(defn own? [user dbo]
  (= user (:user dbo)))

(defn transform-using [blog transform-rules]
  (let [dropped (apply dissoc blog (:drop transform-rules))
        tf-fns (:transform transform-rules)
        transformed (merge dropped (reduce (fn [m [key transform]]
                                             (assoc m key (transform (key dropped))))
                                             {}
                                             (select-keys
                                                tf-fns
                                                (vec (clojure.set/intersection (set (keys dropped))
                                                                               (set (keys tf-fns)))))))]
    (if (every? identity ((apply juxt (:validation transform-rules)) transformed))
      transformed
      (error "cannot validate blog object" blog))))

(def from-db-transform
  {:drop []
