Hyperbee
API Docs | https://github.com/hypercore-protocol/hyperbee |
Depends On | hypercore |
An append-only Btree running on a Hypercore. Allows sorted iteration and more.
const Hyperbee = require('hyperbee')
const db = new Hyperbee(feed, {
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
valueEncoding: 'binary' // same options as above
})
// if you own the feed
await db.put('key', 'value')
await db.del('some-key')
// if you want to query the feed
const node = await db.get('key') // null or { key, value }
// if you want to read a range
const rs = db.createReadStream({ gt: 'a', lt: 'd' }) // anything >a and <d
const rs = db.createReadStream({ gte: 'a', lte: 'd' }) // anything >=a and <=d