Skip to content
Snippets Groups Projects
Commit e4e55ca9 authored by Federico Hurtado's avatar Federico Hurtado
Browse files

contact and degree repository to save data to db.

parent 88668598
No related branches found
No related tags found
1 merge request!2able to bypass cas in localhost
const { pool } = require("../config/database/database.config");
// contacts: [
// {
// contactNumber: string --> i guess this can be a phone nunber, email, etc.
// contactType: string --> need to define list: phone, email, ....
// preferredContact: boolean
// },
async function addContact(contact, peopleId) {
// extract the parts of the contact
let { contactNumber, contactType, preferredContact } = contact;
console.log("adding contact....");
try {
// query for adding the contact
const query = `
INSERT INTO peopleContact (peopleId, contactNumber, contactType, preferredContact)
VALUES (?,?,?,?)
`;
// insert data into db
const [results] = await pool.query(query, [
peopleId,
contactNumber,
contactType,
preferredContact,
]);
return results;
} catch (error) {
console.log(error);
}
}
module.exports = { addContact };
...@@ -14,7 +14,7 @@ async function addDegree(degree, peopleId) { ...@@ -14,7 +14,7 @@ async function addDegree(degree, peopleId) {
try { try {
// Use the helper function to determine the degreeTypeId // Use the helper function to determine the degreeTypeId
degreeTypeId = await _lookupDegreeTypeId(degreeType); let degreeTypeId = await _lookupDegreeTypeId(degreeType);
const query = ` const query = `
INSERT INTO peopleDegree (peopleId, degreeTypeId, degreeDepartment, degreeCollege, degreeYear, degreeDescription) INSERT INTO peopleDegree (peopleId, degreeTypeId, degreeDepartment, degreeCollege, degreeYear, degreeDescription)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment