levelup that uses a leveldown that writes to a changes feed to store its state
Clone or download
Latest commit 35e3fc0 Mar 7, 2015
Permalink
Failed to load latest commit information.
.gitignore first commit Jan 15, 2015
.travis.yml add travis Jan 15, 2015
LICENSE first commit Jan 15, 2015
README.md add createChangesStream Mar 4, 2015
changesdown.js upgrade subleveldown Jan 30, 2015
encoding.js use string enums Jan 16, 2015
example.js add createChangesStream Mar 4, 2015
index.js add createChangesStream Mar 4, 2015
package.json 2.3.1 Mar 7, 2015
schema.proto use string enums Jan 16, 2015
test.js use string enums Jan 16, 2015

README.md

changesdown

levelup that uses a leveldown that writes to a changes feed to store its state

npm install changesdown

build status

Usage

var changesdown = require('changesdown')
var changes = require('changes-feed')
var level = require('level')

var feed = changes(level('changes'))
var db = changesdown(level('db'), feed)

db.put('hello', 'world', function() {
  db.get('hello', function(err, value) {
    console.log(value) // should print world
  })
})

db.createChangesStream({live:true})
  .on('data', function(data) {
    console.log('change:', data.value) // should print some changes
  })

API

db = changesdown(levelup, changesFeed, [options])

Returns a new levelup (db) that reads and writes from the changes feed. The levelup you pass in is used to store a view of the feed.

Any options passed will be forwarded to the levelup constructor.

stream = db.createChangesStream(opts)

Read from the changes stream and decode the changes value with the same encoding that was used in the levelup.

For example if you pass {valueEncoding: 'json'} the values will be decoded as JSON instead of buffers

License

MIT