Added test and query call

This commit is contained in:
Naida Vatric
2019-11-01 01:16:23 +01:00
parent 03a7086162
commit 0ed5fb89c3
7 changed files with 84 additions and 68 deletions

View File

@@ -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')

View File

@@ -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
}