20 lines
513 B
JavaScript
20 lines
513 B
JavaScript
//Call for listing all groups with their users - needed for control panel
|
|
//
|
|
const handleListGroup = (req, res, db) => {
|
|
db.transaction (trx => {
|
|
trx.select('*')
|
|
.from('groups')
|
|
.orderBy('groupname', 'asc')
|
|
.orderBy('username', 'asc')
|
|
.then( data => {
|
|
res.json(data);
|
|
})
|
|
.then(trx.commit)
|
|
.catch(trx.rollback)
|
|
.catch (err => res.status(400).json('Error accesing database.'))
|
|
})
|
|
}
|
|
|
|
module.exports = {
|
|
handleListGroup
|
|
} |