mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
experience update
This commit is contained in:
@ -17,8 +17,8 @@ function createExperience(title, description, organizationId, organizationName,
|
||||
const experience = {
|
||||
title,
|
||||
description,
|
||||
organization_id: organizationId,
|
||||
organization_name: organizationName,
|
||||
organization_id: organizationId, // Either OrganizationId or OrganizationName should be set, not both (TODO in validator)
|
||||
organization_name: organizationName, // Either OrganizationId or OrganizationName should be set, not both (TODO in validator)
|
||||
date,
|
||||
person_id,
|
||||
type
|
||||
@ -26,17 +26,40 @@ function createExperience(title, description, organizationId, organizationName,
|
||||
return experience;
|
||||
}
|
||||
|
||||
async function insert(experience){
|
||||
async function insert(experience) {
|
||||
const insertedExperience = await knex('Experience')
|
||||
.insert(experience)
|
||||
.returning('*');
|
||||
.insert(experience)
|
||||
.returning('*');
|
||||
return insertedExperience[0];
|
||||
}
|
||||
|
||||
async function findById(experienceId) {
|
||||
return await knex('Experience').where({
|
||||
id: experienceId
|
||||
}).select().first();
|
||||
}
|
||||
|
||||
async function remove(experienceId) {
|
||||
await knex('Experience')
|
||||
.where({
|
||||
id: experienceId
|
||||
})
|
||||
.del();
|
||||
}
|
||||
|
||||
async function update(experience) {
|
||||
await knex('Experience')
|
||||
.where('id', experience.id)
|
||||
.update(experience);
|
||||
}
|
||||
|
||||
// Exporting a function
|
||||
// means making a JavaScript function defined in one
|
||||
// module available for use in another module.
|
||||
module.exports = {
|
||||
createExperience,
|
||||
insert
|
||||
insert,
|
||||
findById,
|
||||
remove,
|
||||
update
|
||||
};
|
@ -120,9 +120,9 @@ async function authenticate(email, password) {
|
||||
* @param {*} person The Person to update
|
||||
* @param {*} person_id The database id of the Person to update
|
||||
*/
|
||||
async function update(person, person_id) {
|
||||
async function update(person) {
|
||||
await knex('Person')
|
||||
.where('id', person_id)
|
||||
.where('id', person.id)
|
||||
.update(person);
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,8 @@ async function updatePerson(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
await Person.update(updatePerson, req.jwt.person_id);
|
||||
updatePerson.id = req.jwt.person_id;
|
||||
await Person.update(updatePerson);
|
||||
return res.status(204).send();
|
||||
} catch (error) {
|
||||
console.error(`Error in function ${updatePerson.name}: ${error}`);
|
||||
|
@ -55,7 +55,6 @@ function extractToken(req, res, next) {
|
||||
error: 'No token provided'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
Reference in New Issue
Block a user