Added test and query call
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
//Group initialization
|
||||
//Checking if group existis in DB table groups
|
||||
//if no inserts new group with no users (implicitly)
|
||||
|
||||
const handleAddGroup = (reqgroup, db) => {
|
||||
db.transaction (trx => {
|
||||
trx.select('groupname')
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
//Checking if user is a member of a group
|
||||
//if yes returns true else returns false
|
||||
const checkMember = (requser, reqgroup, db) => {
|
||||
let check;
|
||||
db.transaction (trx => {
|
||||
trx.select('username')
|
||||
.from('groups')
|
||||
.where('username', 'ilike', requser)
|
||||
.andWhere('groupname', 'ilike', reqgroup)
|
||||
.then ( data => {
|
||||
if (data.length!==0) {
|
||||
check= true;
|
||||
}
|
||||
check= false;
|
||||
})
|
||||
.then(trx.commit)
|
||||
.catch(trx.rollback)
|
||||
});
|
||||
console.log ('check', check);
|
||||
return check;
|
||||
}
|
||||
module.exports = {
|
||||
checkMember
|
||||
}
|
||||
Reference in New Issue
Block a user