       (ffirst results))))
 
 (defn datoms-of-attrs-as-of
+  "Returns the datoms from the log where each datom's entity id matches entid
+  and its attribute entity ID is of an attribute entity ID belonging to attrs,
+  and with a transaction date as of as-of-inst."
   [conn entid attrs as-of-inst]
   (let [attr-entids (map #(entity-id-for-schema-attribute conn %) attrs)]
     (let [txns (->> (seq (d/tx-range (d/log conn) as-of-inst nil))

                            []))]
      [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)]

                     (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))})
