 (defn contains?
   "Returns true if entity with given id exists in db."
   [db-snap id]
-  (contains?* (get* db-snap :eav) (resolve-id db-snap id)))
+  (let [id (resolve-id db-snap id)]
+    (when id (log-read [:e__] conj [id]))
+    (true? (contains?* (get* db-snap :eav) id))))
 
 (defn- listen-path!
   [db path f]

        (swap! seen-ids conj (datom 0))

        ;; entity-attr listeners
        (doseq [f (get-in* listeners [:entity-attr id a])]
          (f datom))

        ;; attr-val listeners
        (doseq [v (cond-> (or v prev-v)
                          (not (many? a)) (list))]
          (doseq [f (get-in* listeners [:attr-val a v])]
            (f datom)))

        ;; attr listeners
        (doseq [f (get-in* listeners [:attr a])]
          (f datom)))

      (doseq [id @seen-ids]
        (doseq [f (get-in* listeners [:entity id])]
          (f id)))

      ;; tx-log listeners

    (fn [db-snap attr val]
      (let [schema (get-schema db-snap attr)
            prev-val (get* prev-m attr)]
        (cond (many? schema)
              (update-index db-snap id attr
                            (set/difference val prev-val)
                            (set/difference prev-val val)
                            schema)
              (not= val prev-val)
              (update-index db-snap id attr val prev-val schema)
              :else db-snap)))
    db-snap m))

(defn add-map-datoms [datoms id m prev-m db-snap]
