the-tip-top-backend/scripts/get-employee-email.js
2025-11-17 23:47:54 +01:00

21 lines
563 B
JavaScript

import { pool } from '../db.js';
const getEmployee = async () => {
try {
const result = await pool.query(`SELECT email, first_name, last_name FROM users WHERE role = 'EMPLOYEE' LIMIT 1`);
if (result.rows.length > 0) {
const emp = result.rows[0];
console.log(`Email: ${emp.email}`);
console.log(`Nom: ${emp.first_name} ${emp.last_name}`);
} else {
console.log('Aucun employé trouvé');
}
await pool.end();
} catch (error) {
console.error('Erreur:', error.message);
await pool.end();
}
};
getEmployee();