Add CRUD operations for participant
This commit is contained in:
63
api/models/participantModel.js
Normal file
63
api/models/participantModel.js
Normal file
@@ -0,0 +1,63 @@
|
||||
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',
|
||||
'earliest_time',
|
||||
'latest_time',
|
||||
'quorum',
|
||||
'mandatory',
|
||||
'host',
|
||||
'answered',
|
||||
'timezone',
|
||||
]);
|
||||
}
|
||||
|
||||
function updateParticipant(data, account_id, meeting_id) {
|
||||
return db('participant')
|
||||
.where({ account_id, meeting_id })
|
||||
.update(data)
|
||||
.returning([
|
||||
'account_id',
|
||||
'meeting_id',
|
||||
'earliest_time',
|
||||
'latest_time',
|
||||
'quorum',
|
||||
'mandatory',
|
||||
'host',
|
||||
'answered',
|
||||
'timezone',
|
||||
]);
|
||||
}
|
||||
|
||||
function deleteParticipant(id) {
|
||||
return db('participant').where({ id }).del();
|
||||
}
|
||||
|
||||
function getParticipantById(account_id, meeting_id) {
|
||||
return db('participant')
|
||||
.where({ account_id, meeting_id })
|
||||
.first()
|
||||
.select(
|
||||
'account_id',
|
||||
'meeting_id',
|
||||
'earliest_time',
|
||||
'latest_time',
|
||||
'quorum',
|
||||
'mandatory',
|
||||
'host',
|
||||
'answered',
|
||||
'timezone',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user