26 lines
1.0 KiB
JavaScript
26 lines
1.0 KiB
JavaScript
import mysql from 'mysql2/promise';
|
|
|
|
async function checkData() {
|
|
const dbConfig = { host: 'localhost', user: 'root', password: '', database: 'sis_odonto' };
|
|
try {
|
|
const connection = await mysql.createConnection(dbConfig);
|
|
const [dentists] = await connection.query('SELECT * FROM dentistas');
|
|
const [agendamentos] = await connection.query('SELECT * FROM agendamentos');
|
|
console.log('\n--- DENTISTAS ---');
|
|
console.table(dentists.map(d => ({ id: d.id, nome: d.nome })));
|
|
console.log('\n--- AGENDAMENTOS ---');
|
|
console.table(agendamentos.map(a => {
|
|
const d = dentists.find(dent => dent.id === a.dentistaId);
|
|
return {
|
|
id: a.id,
|
|
paciente: a.pacienteNome,
|
|
dentista: d ? d.nome : 'UNKNOWN',
|
|
dentistaId: a.dentistaId,
|
|
startTime: a.start_time
|
|
};
|
|
}));
|
|
await connection.end();
|
|
} catch (err) { console.error('Error:', err.message); }
|
|
}
|
|
checkData();
|