                                :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]
+  [conn attrs]
   (let [new-id (d/tempid :entities)
         {:keys [db-after tempids]} @(d/transact conn
                                                 [(assoc attrs :db/id new-id)])]

    conn
    [[:db/retract [:user/id user-id] :user/open-thread [:thread/id thread-id]]]))

(defn create-tag! [attrs]
  (-> {:tag/id (attrs :id)
       :tag/name (attrs :name)
       :tag/group [:group/id (attrs :group-id)]}
      create-entity!
      db->tag))

(defn tag-group-id [conn tag-id]

  (some? (d/pull (d/db conn) '[:group/id] [:group/name group-name])))

(defn create-group!
  [conn {:keys [name id]}]
  (->> {:group/id id
       :group/name name}
      (create-entity! conn)
      db->group))

(defn email-taken?
