@@ -4,11 +4,11 @@ DB is library managing key value state for MatrixAI's JavaScript/TypeScript appl
4
4
5
5
This forks classic-level's C++ binding code around LevelDB 1.20. Differences from classic-level:
6
6
7
- * Uses TypeScript from ground-up
8
- * Supports Snapshot-Isolation based transactions via ` DBTransaction `
9
- * API supports "key paths" which can be used to manipulate "levels" of nested keys
10
- * Value encryption (key-encryption is not supported yet) - requires additional work with block-encryption
11
- * Uses RocksDB
7
+ - Uses TypeScript from ground-up
8
+ - Supports Snapshot-Isolation based transactions via ` DBTransaction `
9
+ - API supports "key paths" which can be used to manipulate "levels" of nested keys
10
+ - Value encryption (key-encryption is not supported yet) - requires additional work with block-encryption
11
+ - Uses RocksDB
12
12
13
13
## Installation
14
14
@@ -21,26 +21,25 @@ npm install --save @matrixai/db
21
21
``` ts
22
22
import { DB } from ' @matrixai/db' ;
23
23
24
- async function main () {
25
-
24
+ async function main() {
26
25
const key = Buffer .from ([
27
- 0x00 , 0x01 , 0x02 , 0x03 , 0x00 , 0x01 , 0x02 , 0x03 ,
28
- 0x00 , 0x01 , 0x02 , 0x03 , 0x00 , 0x01 , 0x02 , 0x03 ,
26
+ 0x00 , 0x01 , 0x02 , 0x03 , 0x00 , 0x01 , 0x02 , 0x03 , 0x00 , 0x01 , 0x02 , 0x03 ,
27
+ 0x00 , 0x01 , 0x02 , 0x03 ,
29
28
]);
30
29
31
30
const encrypt = async (
32
31
key : ArrayBuffer ,
33
- plainText : ArrayBuffer
32
+ plainText : ArrayBuffer ,
34
33
): Promise <ArrayBuffer > => {
35
34
return plainText ;
36
35
};
37
36
38
37
const decrypt = async (
39
38
key : ArrayBuffer ,
40
- cipherText : ArrayBuffer
39
+ cipherText : ArrayBuffer ,
41
40
): Promise <ArrayBuffer | undefined > => {
42
41
return cipherText ;
43
- }
42
+ };
44
43
45
44
const db = await DB .createDB ({
46
45
dbPath: ' ./tmp/db' ,
@@ -60,11 +59,9 @@ async function main () {
60
59
61
60
await db .del ([' level' , Buffer .from ([0x30 , 0x32 ]), ' c' ]);
62
61
63
- for await (const [kP, v] of db .iterator (
64
- [' level' ],
65
- {
66
- lt: [Buffer .from ([0x30 , 0x32 ]), ' ' ],
67
- })) {
62
+ for await (const [kP, v] of db .iterator ([' level' ], {
63
+ lt: [Buffer .from ([0x30 , 0x32 ]), ' ' ],
64
+ })) {
68
65
console .log (kP , v );
69
66
}
70
67
0 commit comments