   [attrs]
   (let [new-id (d/tempid :entities)
         {:keys [db-after tempids]} @(d/transact conn
-                                                [(assoc attrs :db/id new-id)])]
+                                      [(assoc attrs :db/id new-id)])]
     (->> (d/resolve-tempid db-after tempids new-id)
          (d/entity db-after))))
 

  (if-let [e (user-preference-is-set? user-id k)]
    @(d/transact conn [[:db/add e :user.preference/value (pr-str v)]])
    @(d/transact conn [{:user.preference/key k
                         :user.preference/value (pr-str v)
                         :user/_preferences [:user/id user-id]
                         :db/id #db/id [:entities]}])))

(defn user-search-preferences
  "Find the ids of users that have the a given value for a given key set in

  ; subscribe to a tag they can't?
  (when (user-in-tag-group? user-id tag-id)
    (d/transact conn [[:db/add [:user/id user-id]
                       :user/subscribed-tag [:tag/id tag-id]]])))

(defn user-unsubscribe-from-tag!
  [user-id tag-id]
  (d/transact conn [[:db/retract [:user/id user-id]
                     :user/subscribed-tag [:tag/id tag-id]]]))

(defn user-add-to-group! [user-id group-id]
  (d/transact conn [[:db/add [:group/id group-id]
                     :group/user [:user/id user-id]]]))

(defn user-make-group-admin! [user-id group-id]
  (d/transact conn [[:db/add [:group/id group-id]
                     :group/user [:user/id user-id]]
                    [:db/add [:group/id group-id]
                     :group/admins [:user/id user-id]]]))

(defn user-is-group-admin?
  [user-id group-id]
