2020-05-04 16:47:05 +00:00
|
|
|
const db = require('../../data/db');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
addParticipant,
|
|
|
|
getParticipantById,
|
|
|
|
updateParticipant,
|
|
|
|
deleteParticipant,
|
|
|
|
// getMeetingsByParticipantId,
|
|
|
|
};
|
|
|
|
|
|
|
|
function addParticipant(data) {
|
|
|
|
return db('participant')
|
|
|
|
.insert(data)
|
|
|
|
.returning([
|
|
|
|
'account_id',
|
|
|
|
'meeting_id',
|
|
|
|
'quorum',
|
|
|
|
'mandatory',
|
|
|
|
'host',
|
|
|
|
'answered',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateParticipant(data, account_id, meeting_id) {
|
|
|
|
return db('participant')
|
|
|
|
.where({ account_id, meeting_id })
|
|
|
|
.update(data)
|
|
|
|
.returning([
|
|
|
|
'account_id',
|
|
|
|
'meeting_id',
|
|
|
|
'quorum',
|
|
|
|
'mandatory',
|
|
|
|
'host',
|
|
|
|
'answered',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2020-05-06 13:27:25 +00:00
|
|
|
function deleteParticipant(account_id, meeting_id) {
|
|
|
|
return db('participant').where({ account_id, meeting_id }).del();
|
2020-05-04 16:47:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getParticipantById(account_id, meeting_id) {
|
|
|
|
return db('participant')
|
|
|
|
.where({ account_id, meeting_id })
|
|
|
|
.first()
|
|
|
|
.select(
|
|
|
|
'account_id',
|
|
|
|
'meeting_id',
|
|
|
|
'quorum',
|
|
|
|
'mandatory',
|
|
|
|
'host',
|
|
|
|
'answered',
|
|
|
|
);
|
|
|
|
}
|