     conn
     [[:db/retract [:user/id user-id] :user/open-thread [:thread/id thread-id]]]))
 
-(defn create-tag! [attrs]
-  (-> {:tag/id (attrs :id)
+(defn create-tag!
+  [conn attrs]
+  (->> {:tag/id (attrs :id)
        :tag/name (attrs :name)
        :tag/group [:group/id (attrs :group-id)]}
-      create-entity!
+      (create-entity! conn)
       db->tag))
 
 (defn tag-group-id [conn tag-id]

                               :type (:extension/type x)})
                      (:extension/_group e))}))

(defmacro with-conn
  "Execute the body with *conn* dynamically bound to a new connection."
  [& body]
  `(binding [*conn* (d/connect *uri*)]
     ~@body))

(defn- create-entity!
  "create entity with attrs, return entity"
  [attrs]
  (let [new-id (d/tempid :entities)
        {:keys [db-after tempids]} @(d/transact conn
                                                [(assoc attrs :db/id new-id)])]


(defn create-user!
  "creates a user, returns id"
  [conn {:keys [id email avatar nickname password]}]
  (->> {:user/id id
       :user/email email
       :user/avatar avatar
       :user/nickname (or nickname (-> email (string/split #"@") first))
       :user/password-token (password/encrypt password)}
      (create-entity! conn)
      db->user))

(defn nickname-taken?
