level-livefeed
Live query a range in leveldb
Last updated 10 years ago by raynos .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install level-livefeed 
SYNC missed versions from official npm registry.

level-livefeed

Live query a range in leveldb

Example

You query a range in the database. It will load the range from disk and then also add on anything else you put or del from it.

It's basically a never ending feed like tail -f

var livefeed = require("..")
    , level = require("levelidb")
    , WriteStream = require("write-stream")

    , db = level("/tmp/db-livefeed-example", {
        createIfMissing: true
    })

var stream = livefeed(db, { start: "foo:", end: "foo;" })

stream.pipe(WriteStream(function (chunk) {
    console.log("chunk", chunk.type, chunk.key.toString()
        , chunk.value && chunk.value.toString())
}))

stream.on("loaded", function () {
    console.log("finished loading from disk")
})

setTimeout(function () {
    db.put("foo:some key", "some value")

    db.del("foo:die")

    db.batch([
        { type: "put", key: "foo:one", value: "two" }
        , { type: "del", key: "foo:two" }
    ])
}, 2000)

prints

chunk put foo:one two
chunk put foo:some key some value
finished loading from disk
chunk put foo:some key some value
chunk del foo:die undefined
chunk put foo:one two
chunk del foo:two undefined

Installation

npm install level-livefeed

Contributors

  • Raynos

MIT Licenced

Current Tags

  • 0.2.0                                ...           latest (10 years ago)

5 Versions

  • 0.2.0                                ...           10 years ago
  • 0.1.3                                ...           12 years ago
  • 0.1.2                                ...           12 years ago
  • 0.1.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE