diff --git a/backend/repository/contactRepository.js b/backend/repository/contactRepository.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b096cb2d967d0f29d370514afe3c753c649dbca1 100644 --- a/backend/repository/contactRepository.js +++ b/backend/repository/contactRepository.js @@ -0,0 +1,36 @@ +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 }; diff --git a/backend/repository/degreeRepository.js b/backend/repository/degreeRepository.js index d36e65f0cee7a1c9a114f1fcf92abc46d858f488..9955b1d322a4bc7ed07ee13207e5f1170add0701 100644 --- a/backend/repository/degreeRepository.js +++ b/backend/repository/degreeRepository.js @@ -14,7 +14,7 @@ async function addDegree(degree, peopleId) { try { // Use the helper function to determine the degreeTypeId - degreeTypeId = await _lookupDegreeTypeId(degreeType); + let degreeTypeId = await _lookupDegreeTypeId(degreeType); const query = ` INSERT INTO peopleDegree (peopleId, degreeTypeId, degreeDepartment, degreeCollege, degreeYear, degreeDescription)