34 lines
956 B
TypeScript
34 lines
956 B
TypeScript
#!/usr/bin/env tsx
|
|
/**
|
|
* List all charts in the database
|
|
*/
|
|
|
|
import { db } from '../src/lib/db';
|
|
import { charts } from '../src/lib/db/schema';
|
|
|
|
async function main() {
|
|
console.log('=== Charts in Database ===\n');
|
|
|
|
const allCharts = await db.select().from(charts).orderBy(charts.created_at);
|
|
|
|
if (allCharts.length === 0) {
|
|
console.log('No charts found.\n');
|
|
console.log('To create a chart:');
|
|
console.log('1. Upload a CSV file at http://localhost:3000');
|
|
console.log('2. Or use the create-chart script (coming soon)');
|
|
} else {
|
|
console.log(`Found ${allCharts.length} chart(s):\n`);
|
|
for (const chart of allCharts) {
|
|
const date = chart.created_at.toISOString();
|
|
console.log(` ID: ${chart.id}`);
|
|
console.log(` Name: ${chart.name}`);
|
|
console.log(` Created: ${date}`);
|
|
console.log('');
|
|
}
|
|
}
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error('Error:', error.message);
|
|
process.exit(1);
|
|
});
|