@@ -5,6 +5,7 @@ import { userTeamsSchema } from "../schemas/Relational/userteams.schema";
55import { teamFactionSchema } from "../schemas/Relational/teamfaction.schema" ;
66import { userSchema } from "../schemas/Basic/user.schema" ;
77import { getFaction } from "./faction.service" ;
8+ import { factionSchema } from "../schemas/Basic/faction.schema" ;
89
910export const createTeam = async ( teamName : string , members : number [ ] ) => {
1011
@@ -146,24 +147,30 @@ export const getAllTeamsWithUsers = async () => {
146147 teamId : teamSchema . id ,
147148 teamName : teamSchema . name ,
148149 teamType : teamSchema . type ,
150+ teamFaction : factionSchema . name ,
149151 userId : userSchema . id ,
150152 firstName : userSchema . first_name ,
151153 lastName : userSchema . last_name ,
152154 discordId : userSchema . discord_id ,
155+ permission : userSchema . permission ,
153156 } )
154157 . from ( teamSchema )
155158 . innerJoin ( userTeamsSchema , eq ( teamSchema . id , userTeamsSchema . team_id ) )
156- . innerJoin ( userSchema , eq ( userSchema . id , userTeamsSchema . user_id ) ) ;
159+ . innerJoin ( userSchema , eq ( userSchema . id , userTeamsSchema . user_id ) )
160+ . innerJoin ( teamFactionSchema , eq ( teamSchema . id , teamFactionSchema . team_id ) )
161+ . innerJoin ( factionSchema , eq ( factionSchema . id , teamFactionSchema . faction_id ) ) ;
157162
158163 const teamsMap = new Map < number , {
159164 id : number ;
160165 name : string ;
161166 type : string ;
167+ faction : string ;
162168 users : Array < {
163169 id : number ;
164170 firstName : string ;
165171 lastName : string ;
166172 discordId : string ;
173+ permission : string ;
167174 } > ;
168175 } > ( ) ;
169176
@@ -173,6 +180,7 @@ export const getAllTeamsWithUsers = async () => {
173180 id : row . teamId ,
174181 name : row . teamName ,
175182 type : row . teamType ,
183+ faction : row . teamName ,
176184 users : [ ] ,
177185 } ) ;
178186 }
@@ -182,6 +190,7 @@ export const getAllTeamsWithUsers = async () => {
182190 firstName : row . firstName ,
183191 lastName : row . lastName ,
184192 discordId : row . discordId ,
193+ permission : row . permission
185194 } ) ;
186195 }
187196
0 commit comments