npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollbackdb

v2.0.0

Published

A simple key/value database with fast rollback support.

Downloads

7

Readme

rollbackdb

A simple key/value database with fast rollback support.

npm install rollbackdb

build status dat

Usage

var rollbackdb = require('rollbackdb')
// OBS: currently you have use the latest leveldown (>=1.2.0)
var db = require('levelup')('db', {db: require('leveldown')})

var rdb = rollbackdb(db)

rdb.put('hello', 'world', function () {
  var oldChange = rdb.changes
  console.log('added hello world at change', rdb.changes)
  rdb.put('hello', 'not world', function () {
    console.log('added hello not world at change', rdb.changes)
    rdb.get('hello', {version: oldChange}, console.log) // prints 'world'
  })
})

API

rdb = rollbackdb(levelup, [options])

Create a new rollbackdb instance. You can set version in options if you want to rollback the database to a previous version

checkoutRdb = rdb.checkout(version)

Shorthand for setting the version option in the constructor. Returns a new instance.

rdb.get(key, [options], cb)

Get a key. Set version in the options map to get the key that was added in a previous version of this database.

rdb.put(key, value, [cb])

Insert a key.

rdb.del(key, [cb])

Delete a key.

rdb.batch(batch, [cb])

Insert and/or deletes a batch of key/values

rdb.batch([{
  type: 'put',
  key: 'a',
  value: 'a'
}, {
  type: 'del',
  key: 'b',
  value: 'b'
}], function (err) {
  console.log('batch finished')
})

rdb.changes

A property containing the total number of changes/versions added to this database

rs = rdb.createChangesStream([options])

Returns a readable stream of all changes added to this database.

You can limit the range of changes returned by using the following options

{
  gt: changeNumber,
  gte: changeNumber,
  lt: changeNumber,
  lte: changeNumber
}

If you only want a single change stream returned set options.change = changeNumber

rs = rdb.createReadStream([options])

Create a readable stream of all keys and values in the database. Options include

{
  gt: 'keys-must-be-greater-than-me',
  gte: 'keys-must-be-greater-or-equal-to-me',
  lt: 'keys-must-be-less-than-me',
  lte: 'keys-must-be-less-or-equal-to-me',
  version: aVersionNumber // read all values in the database at this version
}

ws = rdb.createWriteStream()

Returns a writable stream that you can write {type: 'put'|'del', key: key, value: value} pairs to. All values written will be added to the same version.

License

MIT