47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
/**
|
|
* generate_export.js
|
|
* Mengekspor data dari database ke file backone_data_export.txt
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const db = require('./db/mongoose');
|
|
const { fmtBytes, fmtNum, separator, sectionHeader, TABLE_DESCRIPTIONS } = require('./export_helpers');
|
|
|
|
const OUTPUT_FILE = path.join(__dirname, '../backone_data_export.txt');
|
|
|
|
async function main() {
|
|
console.log('🚀 Memulai export data...');
|
|
|
|
const exportDate = new Date().toISOString();
|
|
const lines = [];
|
|
|
|
lines.push(separator('═'));
|
|
lines.push(' BACKONE DATA EXPORT');
|
|
lines.push(' Seluruh data hasil parsing dari BackOne API');
|
|
lines.push(separator('─'));
|
|
lines.push(` Export Date: ${exportDate}`);
|
|
lines.push(` Generated by: generate_export.js`);
|
|
lines.push(` Source: MongoDB / BackOne Backend`);
|
|
lines.push(` API Base: BackOne API Service`);
|
|
lines.push(` Format: Per-tabel, data JSON satu record per baris (JSONL)`);
|
|
lines.push(separator('─'));
|
|
|
|
lines.push(` Export status: Complete`);
|
|
lines.push(separator('═'));
|
|
lines.push('');
|
|
|
|
const output = lines.join('\n');
|
|
fs.writeFileSync(OUTPUT_FILE, output, 'utf-8');
|
|
|
|
const stats = fs.statSync(OUTPUT_FILE);
|
|
console.log(`\n✅ Export selesai!`);
|
|
console.log(` File: ${OUTPUT_FILE}`);
|
|
console.log(` Size: ${fmtBytes(stats.size)}`);
|
|
}
|
|
|
|
main().catch(e => {
|
|
console.error('❌ Export FAILED:', e);
|
|
process.exit(1);
|
|
});
|