Files
clube67_newwhats.local/base-scoreodonto/scoreodonto/check_db.js
T
VPS 4 Deploy Agent 5ec6bd6354
continuous-integration/webhook Falha no deploy de clube67_newwhats.local (VPS 4)
chore(ops): migrate clube67 to newwhats.clube67.com directory
2026-05-18 03:26:41 +02:00

43 lines
1.3 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);
console.log('Connected to MySQL');
const [dentists] = await connection.query('SELECT * FROM dentistas');
console.log('\n--- DENTISTAS ---');
console.table(dentists.map(d => ({ id: d.id, nome: d.nome })));
const [agendamentos] = await connection.query('SELECT * FROM agendamentos');
console.log('\n--- AGENDAMENTOS (Counts per Dentist) ---');
const counts = {};
agendamentos.forEach(a => {
counts[a.dentistaId] = (counts[a.dentistaId] || 0) + 1;
});
const countsTable = Object.entries(counts).map(([id, count]) => {
const d = dentists.find(dentist => dentist.id === id);
return {
dentistId: id,
nome: d ? d.nome : 'UNKNOWN (Maybe deleted or not assigned)',
count: count
};
});
console.table(countsTable);
await connection.end();
} catch (err) {
console.error('Error:', err.message);
}
}
checkData();