first commit (nonfunctional)

This commit is contained in:
Siddharth S Singh 2024-08-23 16:25:34 +05:30
parent 8adc87f1d9
commit 9298bf6608
3 changed files with 43 additions and 17 deletions

View file

@ -48,6 +48,7 @@
"@std/streams": "jsr:@std/streams@^0.223.0",
"comlink": "npm:comlink@^4.4.1",
"comlink-async-generator": "npm:comlink-async-generator@^0.0.1",
"commander": "npm:commander@12.1.0",
"deno-safe-fetch/load": "https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts",
"deno.json": "./deno.json",
"entities": "npm:entities@^4.5.0",

6
deno.lock generated
View file

@ -60,6 +60,7 @@
"npm:comlink-async-generator": "npm:comlink-async-generator@0.0.1",
"npm:comlink-async-generator@^0.0.1": "npm:comlink-async-generator@0.0.1",
"npm:comlink@^4.4.1": "npm:comlink@4.4.1",
"npm:commander@12.1.0": "npm:commander@12.1.0",
"npm:entities@^4.5.0": "npm:entities@4.5.0",
"npm:fast-stable-stringify@^1.0.0": "npm:fast-stable-stringify@1.0.0",
"npm:formdata-helper@^0.3.0": "npm:formdata-helper@0.3.0",
@ -543,6 +544,10 @@
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
"dependencies": {}
},
"commander@12.1.0": {
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
"dependencies": {}
},
"cross-spawn@7.0.3": {
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dependencies": {
@ -1904,6 +1909,7 @@
"npm:@scure/base@^1.1.6",
"npm:comlink-async-generator@^0.0.1",
"npm:comlink@^4.4.1",
"npm:commander@12.1.0",
"npm:entities@^4.5.0",
"npm:fast-stable-stringify@^1.0.0",
"npm:formdata-helper@^0.3.0",

View file

@ -1,9 +1,23 @@
import { Storages } from '@/storages.ts';
import { Command } from 'commander';
const store = await Storages.db();
console.warn('Exporting events...');
interface ExportFilter {
authors: string[];
}
if (import.meta.main) {
const exporter = new Command()
.name('db:export')
.description('Export the specified set of events from the Ditto database.')
.version('0.1.0')
.showHelpAfterError();
exporter
// .option('')
.action(async (args: ExportFilter) => {
console.warn('Exporting events...');
let count = 0;
for await (const msg of store.req([{}])) {
@ -21,4 +35,9 @@ for await (const msg of store.req([{}])) {
}
console.warn(`Exported ${count} events`);
});
exporter.parse(Deno.args, { from: 'user' });
}
Deno.exit();