Filter
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user