 
 (comment
   (db/with-db [conn {}]
-    (->> (read-stream conn (UUID/fromString "61e51981-bbd3-4298-a7a6-46109e39dd52"))
-         (map events/sorted-keys))))
+    (read-stream conn (UUID/fromString "61e51981-bbd3-4298-a7a6-46109e39dd52"))))

;; The license text is at http://www.apache.org/licenses/LICENSE-2.0

(ns territory-bro.event-store
  (:require [territory-bro.db :as db]
            [territory-bro.events :as events])
  (:import (java.util UUID)))


    (keyword s)
    s))

(defn- sorted-keys [event]
  ;; sorted maps are slower to access than hash maps,
  ;; so we use them in only dev mode for readability
  (if (:dev config/env)
    (events/sorted-keys event)
    event))

(defn- parse-db-row [row]
  (-> (:data row)
      *json->event*
      (assoc :event/stream-id (:stream_id row)
             :event/stream-revision (:stream_revision row)
             :event/global-revision (:global_revision row))
      (update :event/type coerce-keyword)
      (sorted-keys)))

(defn read-stream
  ([conn stream-id]
