                      (when last-datom
                        (not (.added last-datom)))))
                  attr-entids))))
+
+(defn change-log
+  "Returns a map with 2 keys: :updates and :deletions.  The value at each key is
+  a vector of entities that have either been updated (add/update) or deleted as
+  of as-of-instant.  Each vector contains a collection of entries as maps.  The
+  parameters updated-entry-maker-fn and deleted-entry-maker-fn are used to
+  construct the maps.  updated-entry-maker-fn will be used to contruct the maps
+  to go into the :updates vector; deleted-entry-maker-fn will be used to
+  construct the maps to go into the :deletions vector.  Each of these functions
+  will receive the populated Datomic entity, and is to return a map.  Updates
+  and deletions of entities containing reqd-attr will be included in the
+  computation."
+  [conn
+   as-of-instant
+   reqd-attr
+   updated-entry-maker-fn
+   deleted-entry-maker-fn]
+  {:updates (entities-updated-as-of conn as-of-instant [reqd-attr] updated-entry-maker-fn)
+   :deletions (let [ent-ids (entities-of-attrs-as-of conn [reqd-attr] as-of-instant)]
+                (reduce (fn [deleted-entities ent-id]
+                          (let [is-deleted (are-attributes-retracted-as-of conn
+                                                                           ent-id
+                                                                           [reqd-attr]
+                                                                           as-of-instant)]
+                            (if is-deleted
+                              (conj deleted-entities
+                                    (deleted-entry-maker-fn {:db/id ent-id}))
+                              deleted-entities)))
+                        []
+                        ent-ids))})

                            []))]
      [txns attr-entids])))

(defn are-attributes-retracted-as-of
  [conn entid attrs as-of-inst]
  (let [[datoms attr-entids] (datoms-of-attrs-as-of conn entid attrs as-of-inst)]

               (= parent-entid (get-in entity [parent-attr :db/id])))
      [entity-entid (dissoc entity parent-attr)])))

(defn entity-id-for-schema-attribute
  "Returns the entity ID of attr."
  [conn attr]
  (let [results (d/q '[:find ?attr-ent
                       :in $ ?attr
