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


(defn user-by-id
  [id]
  (some-> (d/pull (d/db *conn*) '[:user/id :user/avatar :user/nickname] [: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])
          db->user))

(defn create-invitation!

(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))

