34 lines
908 B
JavaScript
34 lines
908 B
JavaScript
import pg from 'pg';
|
|
|
|
const pool = new pg.Pool({
|
|
connectionString: 'postgresql://edumanager:EduManager2026!Seguro@150.230.87.131:5432/edumanager'
|
|
});
|
|
|
|
async function run() {
|
|
try {
|
|
const { rows } = await pool.query('SELECT data FROM school_data WHERE id = 1');
|
|
const data = rows[0]?.data;
|
|
if (!data) {
|
|
console.log('No data found.');
|
|
return;
|
|
}
|
|
|
|
console.log('--- CHAVES NO JSONB ---');
|
|
for (const key of Object.keys(data)) {
|
|
if (Array.isArray(data[key])) {
|
|
console.log(`- ${key}: Array com ${data[key].length} itens`);
|
|
} else if (typeof data[key] === 'object' && data[key] !== null) {
|
|
console.log(`- ${key}: Objeto com chaves [${Object.keys(data[key]).join(', ')}]`);
|
|
} else {
|
|
console.log(`- ${key}: ${typeof data[key]}`);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
console.error(err);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
run();
|