   (str "DELETE FROM " (qualified-current)
        " WHERE version = ?"))
 
-(defn- delete-current [db features]
+(defn- delete-current [db versions]
   (try
-    (let [records (map (juxt #(first (rest (:_all_versions %)))) features)]
+    (let [records (map #(vector %) versions)]
       (j/execute! db (cons (delete-current-sql) records) :multi? true :transaction? false))
     (catch java.sql.SQLException e (j/print-sql-exception-chain e))))
 

  (proj/close-feature [_ feature]
    (proj/new-feature _ feature))
  (proj/delete-feature [_ feature]
    nil)
  (proj/close [this]
    (flush-all db new-current-batch delete-current-batch new-history-batch)
    this)
  )


        batched-delete (with-batch dcb dcb-size (partial new-current db) flush-fn)]
    (fn [f]
      (cache-batched-new f)
      (batched-delete (first (rest (:_all_versions f)))))))

(defn- batched-deleter [db dcb dcb-size dhb dhb-size flush-fn feature-cache]
  "Cache batched deleter (thrasher) of current and history"
  (let [batched-delete-cur (with-batch dcb dcb-size (partial delete-current db) flush-fn)
        cache-batched-delete-cur (with-cache feature-cache batched-delete-cur cache-store-key cache-invalidate)
        batched-delete-his (with-batch dhb dhb-size (partial delete-history db) flush-fn)]
    (fn [f]
      (cache-batched-delete-cur (:_version f))
      (batched-delete-his f))))

(deftype Timeline [db root-fn path-fn
                   feature-cache cache-loader
                   new-current-batch new-current-batch-size
                   delete-current-batch delete-current-batch-size
                   new-history-batch new-history-batch-size
                   delete-history-batch delete-history-batch-size
                   flush-fn]
  proj/Projector
  (init [this]
    (init db) this)
  (proj/new-feature [_ feature]
    (let [[dataset collection id] (feature-key feature)
          [root-col root-id] (root-fn dataset collection id)
          path (path-fn dataset collection id)
          batched-new (with-batch new-current-batch new-current-batch-size (partial new-current db) flush-fn)
          cache-batched-new (with-cache feature-cache batched-new cache-store-key cache-value)
          cache-batched-update (batched-updater db new-current-batch new-current-batch-size
                                          delete-current-batch delete-current-batch-size
                                          flush-fn feature-cache)
          batched-history (with-batch new-history-batch new-history-batch-size (partial new-history db) flush-fn)
          cached-get-current (use-cache feature-cache cache-use-key cache-loader)]
      (if-let [current (cached-get-current dataset root-col root-id)]
        (let [new-current (merge current path feature)]
          (if (= (:action feature) :close)
