This commit is contained in:
RochesterX
2025-11-26 22:52:05 -05:00
parent 344d46d89e
commit 4a0199cda6
5 changed files with 40 additions and 5 deletions

View File

@@ -161,11 +161,15 @@ app.post("/toggleWatched", authenticate, async (req, res) => {
});
app.post("/getPlayers", authenticate, async (req, res) => {
const { player } = req.body;
const { player, positions } = req.body;
const result = await pool.request()
.input("query", sql.VarChar, player)
.query(`SELECT p.PlayerID, p.PlayerName, c.TotalValue, p.Team, p.Position FROM Player AS p JOIN Contract AS c ON p.PlayerID = c.PlayerID WHERE p.PlayerName LIKE '%' + @query + '%'`);
.input("one", sql.VarChar, positions[0])
.input("two", sql.VarChar, positions[1])
.input("three", sql.VarChar, positions[2])
.input("four", sql.VarChar, positions[3])
.query(`SELECT p.PlayerID, p.PlayerName, c.TotalValue, p.Team, p.Position FROM Player AS p JOIN Contract AS c ON p.PlayerID = c.PlayerID WHERE p.PlayerName LIKE '%' + @query + '%' AND p.Position IN (@one, @two, @three, @four);`);
res.status(200).json({ query: player, matches: result.recordset });
});