70 lines
1.1 KiB
JavaScript
70 lines
1.1 KiB
JavaScript
const db = require('../../data/db');
|
|
|
|
module.exports = {
|
|
addAccount,
|
|
getAccountById,
|
|
updateAccount,
|
|
deleteAccount,
|
|
// getMeetingsByAccountId,
|
|
};
|
|
|
|
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',
|
|
);
|
|
}
|