25 lines
661 B
TypeScript
25 lines
661 B
TypeScript
import * as assert from 'assert'
|
|
|
|
suite('Database Test Suite', () => {
|
|
test('Test database', () => {
|
|
const level = require('level-rocksdb')
|
|
|
|
// 1) Create our database, supply location and options.
|
|
// This will create or open the underlying RocksDB store.
|
|
const db = level('./mydb')
|
|
|
|
// 2) Put a key & value
|
|
db.put('name', 'Level', function (err: any) {
|
|
if (err) return console.log('Ooops!', err) // some kind of I/O error
|
|
|
|
// 3) Fetch by key
|
|
db.get('name', function (err: any, value: any) {
|
|
if (err) return console.log('Ooops!', err) // likely the key was not found
|
|
|
|
// Ta da!
|
|
console.log('name=' + value)
|
|
})
|
|
})
|
|
})
|
|
})
|