@@ -4,11 +4,11 @@ DB is library managing key value state for MatrixAI's JavaScript/TypeScript appl
44
55This forks classic-level's C++ binding code around LevelDB 1.20. Differences from classic-level:
66
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
1212
1313## Installation
1414
@@ -21,26 +21,25 @@ npm install --save @matrixai/db
2121``` ts
2222import { DB } from ' @matrixai/db' ;
2323
24- async function main () {
25-
24+ async function main() {
2625 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 ,
2928 ]);
3029
3130 const encrypt = async (
3231 key : ArrayBuffer ,
33- plainText : ArrayBuffer
32+ plainText : ArrayBuffer ,
3433 ): Promise <ArrayBuffer > => {
3534 return plainText ;
3635 };
3736
3837 const decrypt = async (
3938 key : ArrayBuffer ,
40- cipherText : ArrayBuffer
39+ cipherText : ArrayBuffer ,
4140 ): Promise <ArrayBuffer | undefined > => {
4241 return cipherText ;
43- }
42+ };
4443
4544 const db = await DB .createDB ({
4645 dbPath: ' ./tmp/db' ,
@@ -60,11 +59,9 @@ async function main () {
6059
6160 await db .del ([' level' , Buffer .from ([0x30 , 0x32 ]), ' c' ]);
6261
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+ })) {
6865 console .log (kP , v );
6966 }
7067
0 commit comments