File size: 1,050 Bytes
8b105ad
 
 
 
 
 
 
 
 
 
 
051fc03
 
 
 
 
8b105ad
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const {runQuery, runSelectQuery} = require('./queries');

// Check existing job application
async function checkExistingJobApplication(name, email, role) {
    const checkQuery = `SELECT * FROM applicants WHERE name = ? AND email = ? AND role = ?;`;
    const results = await runSelectQuery(checkQuery, [name, email, role]);
    console.log(results);
    return results.length > 0;
}

// Insert job application
async function insertJobApplication(name, email, phone, experience, role, linkedin, resume, filename, consent, policyVersion) {
    const insertQuery = `INSERT INTO applicants (date, time, name, email, phone, experience, role, linkedin, resume, filename, consent, policyVersion) VALUES (DATE("now"), TIME("now"), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`;
    const boolConsent = Number(consent === "true");
    console.log(typeof(boolConsent));
    await runQuery(insertQuery, [name, email, phone, experience, role, linkedin, resume, filename, boolConsent, policyVersion]);
}

module.exports = { checkExistingJobApplication, insertJobApplication };