Delete teams
This commit is contained in:
parent
075d2f4489
commit
0ae9c54755
|
@ -137,6 +137,23 @@ api.get("/team/:teamId", (req, res) => {
|
|||
.catch(err => res.send({"status": "error", "data": err}));
|
||||
});
|
||||
|
||||
api.post("/team/:teamId/delete", (req, res) => {
|
||||
let teamId = req.params.teamId;
|
||||
if (isNaN(teamId)) {
|
||||
res.json({"status": "error", "data": "teamId must be a number"});
|
||||
return
|
||||
}
|
||||
try {
|
||||
teamId = parseInt(teamId);
|
||||
} catch (err) {
|
||||
res.json({"status": "error", "data": "teamId must be a number"});
|
||||
return
|
||||
}
|
||||
tmdb.deleteTeam(teamId)
|
||||
.then(match => res.send({"status": "OK", "data": match}))
|
||||
.catch(err => res.send({"status": "error", "data": err}));
|
||||
});
|
||||
|
||||
api.post("/team/:teamId/edit", (req, res) => {
|
||||
let teamId = req.params.teamId;
|
||||
let teamName = req.body.name;
|
||||
|
|
|
@ -33,9 +33,9 @@ CREATE TABLE matches (
|
|||
tier INTEGER,
|
||||
|
||||
FOREIGN KEY (tournamentId) REFERENCES tournaments (id),
|
||||
FOREIGN KEY (team1Id) REFERENCES teams (id),
|
||||
FOREIGN KEY (team2Id) REFERENCES teams (id),
|
||||
FOREIGN KEY (winnerId) REFERENCES teams (id)
|
||||
FOREIGN KEY (team1Id) REFERENCES teams (id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (team2Id) REFERENCES teams (id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (winnerId) REFERENCES teams (id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE players (
|
||||
|
|
|
@ -8,6 +8,7 @@ module.exports = {
|
|||
getTeam: getTeam,
|
||||
createTeam: createTeam,
|
||||
editTeam: editTeam,
|
||||
deleteTeam: deleteTeam,
|
||||
getMatch: getMatch,
|
||||
setMatchWinner: setMatchWinner,
|
||||
createTournament: createTournament,
|
||||
|
@ -338,7 +339,6 @@ function deleteTeam(teamId) {
|
|||
console.log(err);
|
||||
reject(err);
|
||||
} else {
|
||||
|
||||
resolve("Team deleted");
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue