import pg from 'pg'; const pool = new pg.Pool({ host: '10.8.8.109', port: 5433, user: 'log_admin', password: 'YourActualStrongPasswordForPostgres!', database: 'log_platform', max: 1 }); const s = await pool.query("SELECT count(*) as total, count(*) FILTER (WHERE dev_loops IS NOT NULL AND dev_loops != '{}'::jsonb) as with_loops, count(*) FILTER (WHERE sys_lock_status IS NOT NULL) as with_lock FROM room_status.room_status_moment"); console.log(JSON.stringify(s.rows[0])); const r = await pool.query("SELECT hotel_id, room_id, device_id, sys_lock_status, dev_loops FROM room_status.room_status_moment WHERE dev_loops IS NOT NULL AND dev_loops != '{}'::jsonb ORDER BY ts_ms DESC LIMIT 3"); console.log('Samples:', r.rows.length); for (const row of r.rows) console.log(JSON.stringify(row)); await pool.end();