Initial commit

This commit is contained in:
Naida Vatric
2019-10-30 23:45:40 +01:00
parent 2948ac6c38
commit 46d32196d9
6 changed files with 3406 additions and 0 deletions

23
endpoints/cleargroup.js Normal file
View File

@@ -0,0 +1,23 @@
//Call for clearing all users from group
//
const handleClearGroup = (req, res, db) => {
//Parsing req body
const { reqgroup} =req.body;
//Checking for groupname in table groups and deleting users
db('groups')
.where('groupname', 'ilike', reqgroup)
.del()
.then (count => {
if (count!==0) {
res.json(`Total of ${count} users cleared from group.`)
}
else {
throw err
}
})
.catch (err => res.status(400).json('Error finding group in database.'))
}
module.exports = {
handleClearGroup
}