Update participant model and routes

This commit is contained in:
2020-08-28 14:08:13 +02:00
parent 9cdf4eedd2
commit d59a562fe2
4 changed files with 36 additions and 39 deletions

View File

@@ -10,7 +10,7 @@ function addAvailability(data) {
.insert(data)
.returning([
'id',
'account_id',
'participant_id',
'meeting_id',
'possible_date_id',
'preference',

View File

@@ -12,6 +12,8 @@ function addParticipant(data) {
return db('participant')
.insert(data)
.returning([
'id',
'email',
'account_id',
'meeting_id',
'quorum',
@@ -21,11 +23,13 @@ function addParticipant(data) {
]);
}
function updateParticipant(data, account_id, meeting_id) {
function updateParticipant(data, id) {
return db('participant')
.where({ account_id, meeting_id })
.where({ id })
.update(data)
.returning([
'id',
'email',
'account_id',
'meeting_id',
'quorum',
@@ -35,15 +39,17 @@ function updateParticipant(data, account_id, meeting_id) {
]);
}
function deleteParticipant(account_id, meeting_id) {
return db('participant').where({ account_id, meeting_id }).del();
function deleteParticipant(id) {
return db('participant').where({id }).del();
}
function getParticipantById(account_id, meeting_id) {
function getParticipantById(id) {
return db('participant')
.where({ account_id, meeting_id })
.where({ id })
.first()
.select(
'id',
'email',
'account_id',
'meeting_id',
'quorum',