-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4ceabd
commit ce9c6d5
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { withF } from '@matrixai/resources'; | ||
import { DB } from './src'; | ||
import * as testsUtils from './tests/utils'; | ||
|
||
async function main () { | ||
|
||
const key = await testsUtils.generateKey(256); | ||
|
||
const db = await DB.createDB({ | ||
dbPath: './tmp/db', | ||
crypto: { | ||
key, | ||
ops: { encrypt: testsUtils.encrypt, decrypt: testsUtils.decrypt }, | ||
}, | ||
fresh: true | ||
}); | ||
|
||
await db.put('key', 'value'); | ||
|
||
const p = db.put('key', 'value3'); | ||
|
||
const t1 = withF([db.transaction()], async ([tran]) => { | ||
const i1 = tran.iterator({ keyAsBuffer: false, valueAsBuffer: false }); | ||
|
||
console.log('CREATED ITERATOR'); | ||
|
||
i1.seek('key') | ||
const v1 = (await i1.next())![1]; | ||
await i1.end(); | ||
|
||
const v2 = await tran.get('key'); | ||
|
||
console.log(v1, v2, v1 === v2); | ||
}); | ||
|
||
await p; | ||
await t1; | ||
|
||
const t2 = withF([db.transaction()], async ([tran]) => { | ||
console.log(await tran.get('key')); | ||
}); | ||
|
||
await t2; | ||
|
||
await db.stop(); | ||
} | ||
|
||
main(); |