                                                :read-handlers
                                                (atom {'konserve.indexeddb.Test
                                                       map->Test})))))
+
     ;; or
     (-jassoc-in my-store ["test" "bar"] #js {:a 3})
     (go (println (<! (-jget-in my-store ["test"]))))

  incognito.

  Be careful not to mix up edn and JSON values."
    [name & {:keys [read-handlers write-handlers serializer]
             :or {read-handlers (atom {})
                  write-handlers (atom {})
                  serializer (ser/string-serializer)}}]
    (let [res (chan)
          req (.open js/window.indexedDB name 1)]
      (set! (.-onerror req)

(ns konserve.indexeddb
  (:require [incognito.edn :refer [read-string-safe]]
            [konserve.core :as k]
            [konserve.serializers :as ser]
            [konserve.protocols :refer [PEDNAsyncKeyValueStore -exists? -get -update-in -assoc-in -get-meta
                                        PBinaryAsyncKeyValueStore -bget -bassoc
                                        PStoreSerializer -serialize -deserialize]]
            [cljs.core.async :as async :refer (take! <! >! put! close! chan poll!)])
  (:require-macros [cljs.core.async.macros :refer [go go-loop]]))


  (defrecord IndexedDBKeyValueStore [db store-name serializer read-handlers write-handlers locks version]
    PEDNAsyncKeyValueStore
    (-exists? [this key]
      (let [res       (chan)
            tx        (.transaction db #js [store-name])
            obj-store (.objectStore tx store-name)
            req       (.openCursor obj-store (pr-str key))]
        (set! (.-onerror req)
              (fn [e]
                (put! res (ex-info "Cannot check for existence."
                                   {:type  :access-error
                                    :key   key
                                    :error (.-target e)}))
                (close! res)))
        (set! (.-onsuccess req)
