Skip to content
Snippets Groups Projects

Resolve "Alert in QI"

Merged Ivar Nordvik Myrstad requested to merge 84-alert-in-qi into dev
Files
4
+ 11
7
@@ -4,7 +4,7 @@ const mongo = require("mongodb");
const MongoClient = mongo.MongoClient;
const connectionUrl = process.env.MONGO_CONNECTION_STRING;
router.delete("/:player", (req, res) => {
router.delete("/:id", (req, res) => {
MongoClient.connect(
connectionUrl,
{ useNewUrlParser: true, useUnifiedTopology: true },
@@ -28,23 +28,26 @@ router.delete("/:player", (req, res) => {
}
// Simply checks if there is a user that matches that exact username and password
db.collection(collection).remove(
db.collection(collection).deleteMany(
{
_playerId: id,
playerId: id
},
(err, result) => {
if (err) {
res.sendStatus(500);
return;
}
res.sendStatus(result);
res.json({
deletedCount: result.deletedCount
});
client.close();
}
);
}
);
});
router.get("/user/:id", (req, res) => {
router.get("/:id", (req, res) => {
MongoClient.connect(
connectionUrl,
{ useNewUrlParser: true, useUnifiedTopology: true },
@@ -70,14 +73,15 @@ router.get("/user/:id", (req, res) => {
// Simply checks if there is a user that matches that exact username and password
db.collection(collection)
.find({
playerId: id,
playerId: id
})
.toArray((err, result) => {
if (err) {
res.sendStatus(500);
return;
}
res.sendStatus(result);
res.json(result);
client.close();
});
}
);
Loading