2020-05-02 19:06:34 +00:00
|
|
|
const db = require('../../data/db');
|
2020-05-01 15:32:46 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2020-05-04 14:02:31 +00:00
|
|
|
addAccount,
|
|
|
|
getAccountById,
|
|
|
|
updateAccount,
|
|
|
|
deleteAccount,
|
|
|
|
// getMeetingsByAccountId,
|
2020-05-01 15:32:46 +00:00
|
|
|
};
|
|
|
|
|
2020-05-04 14:02:31 +00:00
|
|
|
function addAccount(data) {
|
|
|
|
return db('account')
|
|
|
|
.insert(data)
|
|
|
|
.returning([
|
|
|
|
'id',
|
|
|
|
'username',
|
|
|
|
'email',
|
|
|
|
'timezone',
|
|
|
|
'earliest_time',
|
|
|
|
'latest_time',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateAccount(data, id) {
|
|
|
|
return db('account')
|
|
|
|
.where({ id })
|
|
|
|
.update(data)
|
|
|
|
.returning([
|
|
|
|
'id',
|
|
|
|
'username',
|
|
|
|
'email',
|
|
|
|
'timezone',
|
|
|
|
'earliest_time',
|
|
|
|
'latest_time',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteAccount(id) {
|
|
|
|
return db('account').where({ id }).del();
|
|
|
|
}
|
|
|
|
|
|
|
|
// function getMeetingsByAccountId(id) {
|
|
|
|
// // Get all meetings to which an account is participating
|
|
|
|
// // select id, title, description, start_time, timezone, duration, status where
|
|
|
|
// return db('participant')
|
|
|
|
// .where({ id })
|
|
|
|
// .select(
|
|
|
|
// 'id',
|
|
|
|
// 'username',
|
|
|
|
// 'email',
|
|
|
|
// 'timezone',
|
|
|
|
// 'earliest_time',
|
|
|
|
// 'latest_time',
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
function getAccountById(id) {
|
|
|
|
return db('account')
|
|
|
|
.where({ id })
|
|
|
|
.first()
|
|
|
|
.select(
|
|
|
|
'id',
|
|
|
|
'username',
|
|
|
|
'email',
|
|
|
|
'timezone',
|
|
|
|
'earliest_time',
|
|
|
|
'latest_time',
|
|
|
|
);
|
2020-05-01 16:24:59 +00:00
|
|
|
}
|