|
const {runQuery, runSelectQuery} = require('./queries'); |
|
|
|
|
|
async function checkExistingContactRequest(name, email, subject) { |
|
const checkQuery = `SELECT * FROM contact_requests WHERE name = ? AND email = ? AND subject = ?;`; |
|
const results = await runSelectQuery(checkQuery, [name, email, subject]); |
|
return results.length > 0; |
|
} |
|
|
|
|
|
async function insertContactRequest(name, email, phone, subject, message) { |
|
const insertQuery = `INSERT INTO contact_requests (date, time, name, email, phone, subject, message) VALUES (DATE("now"), TIME("now"), ?, ?, ?, ?, ?);`; |
|
await runQuery(insertQuery, [name, email, phone, subject, message]); |
|
} |
|
|
|
module.exports = { checkExistingContactRequest, insertContactRequest }; |