Something like this: ``` clojure (defn- retract-refs-to-entity [db v] (let [schema (:schema db)] (sequence (comp (filter #(= :db.type/ref (get-in schema [(.-a %) :db/valueType]))) (map (fn [d] [:db/retract (.-e d) (.-a d) v]))) (d/-search db [nil nil v])))) ```