      (lhs-view indeces lhs-pk-key lhs-fk-keys join-fn join-pk joined-model lhs-joined-model lhs-unjoined-model))
     ;; view rhses
     (doall
-     (mapv
-      (fn [[rhs-model rhs-pk-key rhs-fk-key rhs-initial-state] i]
-        (log2 :info (str " rhs: " rhs-model ", " i ", " rhs-fk-key))
-        ;; view rhs model
-        (attach rhs-model (rhs-view indeces i rhs-pk-key rhs-fk-key lhs-fk-keys join-fn join-pk joined-model))
-        [{} (or rhs-initial-state {})])
+     (map
+      (fn [[rhs-model rhs-pk-key rhs-fk-key rhs-initial-state rhs-joined-model rhs-unjoined-model] i]
+        (attach rhs-model (rhs-view indeces i rhs-pk-key rhs-fk-key lhs-fk-keys join-fn join-pk joined-model rhs-joined-model rhs-unjoined-model))
+        )
       rhses
       (range)))
     indeces))

	joined-model (versioned-optimistic-map-model (str :joined) :name :version abc-more-recent-than?)
	as-joined-model (versioned-optimistic-map-model (str :as-joined) :name :version >)
	as-unjoined-model (versioned-optimistic-map-model (str :as-unjoined) :name :version >)
	joined-model (versioned-optimistic-map-model (str :joined) :name :version abc-more-recent-than?)
	join (join-model
              "join-model"
              joined-model
              [[as :name [:fk-b :fk-c] as-joined-model as-unjoined-model]
               [bs :name :b]
               [cs :name :c]]
              join-abc :name)
	view (test-view "test")

        old-lhs (lhs-get old-lhs-index key)
        tmp-lhs-indeces (if old-lhs (lhs-dissoc old-lhs-index lhs-pk-key lhs-fk-keys old-lhs) old-lhs-index)
        new-lhs-indeces (lhs-assoc tmp-lhs-indeces lhs-pk-key lhs-fk-keys lhs)
        stale-joins (vals (get-lhs-join-map old-joins key))
	fresh-joins (lhs-join rhs-indeces lhs-fk-keys lhs join-fn)
        tmp-joins (if old-lhs (dissoc-joins old-joins join-pk stale-joins) old-joins)
	new-joins (assoc-joins tmp-joins join-pk fresh-joins)]
    [[new-lhs-indeces rhs-indeces new-joins]
     (fn [_]
       (on-deletes joined-model stale-joins)
       (on-upserts joined-model fresh-joins)
       )]))

(defn- lhs-delete [[old-lhs-indeces rhs-indeces old-joins] lhs-pk-key lhs-fk-keys lhs join-fn join-pk joined-model lhs-joined-model lhs-unjoined-model]
  (let [new-lhs-indeces (lhs-dissoc old-lhs-indeces lhs-pk-key lhs-fk-keys lhs)
        key (lhs-pk-key lhs)
        stale-joins (vals (get-lhs-join-map old-joins key))
	new-joins (dissoc-joins old-joins join-pk stale-joins)]
    [[new-lhs-indeces rhs-indeces new-joins]
     (fn [_]
       (on-deletes joined-model stale-joins))]))

;;; TODO
(defn- lhs-upserts [old-indeces i ks vs join-fn])
