Files
old-naida/helpfunctions/checkmemb.js
2019-10-31 14:27:46 +01:00

24 lines
680 B
JavaScript

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