File tree 1 file changed +7
-15
lines changed
1 file changed +7
-15
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright 2023 the Deno authors. All rights reserved. MIT license.
2
- // Description: Prints kv to stdout
3
- // Usage: deno run -A --unstable tools/dump_kv.ts
4
2
import { kv } from "@/utils/db.ts" ;
5
3
6
4
// https://github.com/GoogleChromeLabs/jsbi/issues/30#issuecomment-521460510
7
5
function replacer ( _key : unknown , value : unknown ) {
8
- return typeof value === "bigint" ? value . toString ( ) : value ; // return everything else unchanged
9
- }
10
- export async function dumpKv ( ) {
11
- const iter = kv . list ( { prefix : [ ] } ) ;
12
- const items = [ ] ;
13
- for await ( const res of iter ) {
14
- items . push ( { [ res . key . toString ( ) ] : res . value } ) ;
15
- }
16
- console . log ( `${ JSON . stringify ( items , replacer , 2 ) } ` ) ;
6
+ return typeof value === "bigint" ? value . toString ( ) : value ;
17
7
}
18
8
19
- if ( import . meta. main ) {
20
- await dumpKv ( ) ;
21
- await kv . close ( ) ;
22
- }
9
+ const iter = kv . list ( { prefix : [ ] } ) ;
10
+ const items = [ ] ;
11
+ for await ( const res of iter ) items . push ( { [ res . key . toString ( ) ] : res . value } ) ;
12
+ console . log ( `${ JSON . stringify ( items , replacer , 2 ) } ` ) ;
13
+
14
+ kv . close ( ) ;
You can’t perform that action at this time.
0 commit comments