 
 (defn user-by-id
   [id]
-  (some-> (d/pull (d/db *conn*) '[:user/id :user/avatar :user/nickname] [:user/id id])
+  (some-> (d/pull (d/db *conn*) user-pull-pattern [:user/id id])
           db->user))
 
 (defn user-with-email
   "get the user with the given email address or nil if no such user registered"
   [email]
-  (some-> (d/pull (d/db *conn*) '[:user/id :user/email :user/avatar :user/nickname] [:user/email email])
+  (some-> (d/pull (d/db *conn*) user-pull-pattern [:user/email email])
           db->user))
 
 (defn create-invitation!

       set))

(defn get-users-in-group [group-id]
  (->> (d/q '[:find (pull ?u [:user/id :user/email :user/nickname :user/avatar])
              :in $ ?group-id
              :where
              [?g :group/id ?group-id]
              [?g :group/user ?u]]
            (d/db *conn*)
            group-id)
       (map (comp db->user first))
       set))


(defn fetch-users-for-user
  "Get all users visible to given user"
  [user-id]
  (->> (d/q '[:find (pull ?e pull-pattern)
              :in $ ?user-id pull-pattern
              :where
              [?u :user/id ?user-id]
              [?g :group/user ?u]
              [?g :group/user ?e]]
            (d/db *conn*)
            user-id
            user-pull-pattern)
       (map (comp db->user first))
       set))

