Spaces:
Sleeping
Sleeping
| import sql from './db'; | |
| async function verify() { | |
| console.log('--- Verifying DB Content ---'); | |
| try { | |
| const countResult = await sql`SELECT COUNT(*) FROM routes`; | |
| const count = countResult[0].count; | |
| console.log(`Total routes in DB: ${count}`); | |
| if (count > 0) { | |
| const sample = await sql`SELECT id, name, path FROM routes LIMIT 5`; | |
| for (const row of sample) { | |
| console.log(`Route ID: ${row.id}, Name: ${row.name}`); | |
| console.log(`Path type: ${typeof row.path}`); | |
| if (row.path && row.path.coordinates) { | |
| const firstPoint = row.path.coordinates[0]; | |
| console.log(`First point: ${JSON.stringify(firstPoint)}`); | |
| } else { | |
| console.log('Path or coordinates missing/invalid structure:', JSON.stringify(row.path).substring(0, 100)); | |
| } | |
| } | |
| } | |
| } catch (err) { | |
| console.error('Error verifying DB:', err); | |
| } finally { | |
| await sql.end(); | |
| } | |
| } | |
| verify(); | |