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}));
|
.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) => {
|
api.post("/team/:teamId/edit", (req, res) => {
|
||||||
let teamId = req.params.teamId;
|
let teamId = req.params.teamId;
|
||||||
let teamName = req.body.name;
|
let teamName = req.body.name;
|
||||||
|
|
|
@ -33,9 +33,9 @@ CREATE TABLE matches (
|
||||||
tier INTEGER,
|
tier INTEGER,
|
||||||
|
|
||||||
FOREIGN KEY (tournamentId) REFERENCES tournaments (id),
|
FOREIGN KEY (tournamentId) REFERENCES tournaments (id),
|
||||||
FOREIGN KEY (team1Id) REFERENCES teams (id),
|
FOREIGN KEY (team1Id) REFERENCES teams (id) ON DELETE SET NULL,
|
||||||
FOREIGN KEY (team2Id) REFERENCES teams (id),
|
FOREIGN KEY (team2Id) REFERENCES teams (id) ON DELETE SET NULL,
|
||||||
FOREIGN KEY (winnerId) REFERENCES teams (id)
|
FOREIGN KEY (winnerId) REFERENCES teams (id) ON DELETE SET NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE players (
|
CREATE TABLE players (
|
||||||
|
|
|
@ -8,6 +8,7 @@ module.exports = {
|
||||||
getTeam: getTeam,
|
getTeam: getTeam,
|
||||||
createTeam: createTeam,
|
createTeam: createTeam,
|
||||||
editTeam: editTeam,
|
editTeam: editTeam,
|
||||||
|
deleteTeam: deleteTeam,
|
||||||
getMatch: getMatch,
|
getMatch: getMatch,
|
||||||
setMatchWinner: setMatchWinner,
|
setMatchWinner: setMatchWinner,
|
||||||
createTournament: createTournament,
|
createTournament: createTournament,
|
||||||
|
@ -338,7 +339,6 @@ function deleteTeam(teamId) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
resolve("Team deleted");
|
resolve("Team deleted");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue