Add db:export command

This commit is contained in:
Alex Gleason
2024-08-02 16:31:39 -05:00
parent 44a61c4a52
commit 9543049419
5 changed files with 53 additions and 10 deletions

16
scripts/db-export.ts Normal file
View File

@@ -0,0 +1,16 @@
import { Storages } from '@/storages.ts';
const store = await Storages.db();
console.warn('Exporting events...');
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] === 'CLOSED') {
console.error('Database closed unexpectedly');
break;
}
}
console.warn('Done!');