Hyperbee 🐝
An append-only Btree running on a Hypercore.
Allows sorted iteration and more.
npm install hyperbee
Usage
const Hyperbee = require('hyperbee')
const db = new Hyperbee(feed, {
keyEncoding: 'utf-8',
valueEncoding: 'binary'
})
await db.put('key', 'value')
await db.del('some-key')
const batch = db.batch()
await batch.put('key', 'value')
await batch.del('some-key')
await batch.flush()
const node = await db.get('key')
const rs = db.createReadStream({ gt: 'a', lt: 'd' })
const rs = db.createReadStream({ gte: 'a', lte: 'd' })
const rs = db.createHistoryStream({ reverse: true, limit: 1 })
Some of the internals are still being tweaked but overall the API and feature set is pretty
stable if you want to try it out.
All of the above methods work with sparse feeds, meaning only a small subset of the full
feed is downloaded to satisfy you queries.