mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-17 21:44:23 +01:00
Add db:export command
This commit is contained in:
16
scripts/db-export.ts
Normal file
16
scripts/db-export.ts
Normal 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!');
|
||||
Reference in New Issue
Block a user