        (defn ~update-fn ~up-args
          (~validate-fn ~'v)
          (~exists! ~up-id)
-         (let [orig# (wcar (car/hgetall* (~id-fn ~up-id) true)) updated# (merge orig#  ~'v)]
+         (let [orig# (wcar (car/hgetall* (~id-fn ~up-id) true)) updated# (merge orig# ~'v)]
            (wcar 
              (~reindex ~up-id orig# updated#) 
              (hsetall* (~id-fn ~up-id) (assoc updated# :meta ~meta*))))))))

    `(do 
       (declare ~validate-fn)

       (defn ~gen-fn []
         (wcar (~id-fn (car/incr ~(<< "~{name*}:ids")))))

       (defn ~add-fn [~'v]

  (let [{:keys [index-add index-del index-get reindex]} (indices-fn-ids name*)
        indices-ks (into [] (map keyword indices))] 
    `(do 
       (defn- ~index-add [~'id ~'v]
         (doseq [i# ~indices-ks]
           (car/sadd (str '~name* i# (get ~'v i#)) ~'id )))

       (defn ~index-get [~'k ~'v]
         (wcar (car/smembers (str '~name* ~'k ~'v))))

       (defn- ~index-del [~'id ~'v]
         (doseq [i# ~indices-ks]
           (wcar (car/srem (str '~name* i# (get ~'v i#)) ~'id))))

        (defn- ~reindex [~'id ~'old ~'new]
          (~index-del ~'id ~'old) 
          (~index-add ~'id ~'new)))))

