Add db:import task

This commit is contained in:
Alex Gleason
2024-08-02 16:54:35 -05:00
parent 3bec54ee76
commit ba3f816955
4 changed files with 44 additions and 3 deletions

View File

@@ -4,13 +4,21 @@ const store = await Storages.db();
console.warn('Exporting events...');
let count = 0;
for await (const msg of store.req([{}])) {
if (msg[0] === 'EVENT') console.log(JSON.stringify(msg[2]));
if (msg[0] === 'EOSE') break;
if (msg[0] === 'EOSE') {
break;
}
if (msg[0] === 'EVENT') {
console.log(JSON.stringify(msg[2]));
count++;
}
if (msg[0] === 'CLOSED') {
console.error('Database closed unexpectedly');
break;
}
}
console.warn('Done!');
console.warn(`Exported ${count} events`);
Deno.exit();