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

multihyperdb

v0.0.2

Published

Manage many [hyperdbs](https://github.com/mafintosh/hyperdb)s

Downloads

3

Readme

MultiHyperDB

Manage many hyperdbss

Installation

npm install multihyperdb

Usage


var multi = require('multihyperdb')

var opts = {
  path: './db',
  dbOpts: {valueEncoding: 'json'}
}

var Multi = multi(opts)

multi.createDB({}, {name: 'First database'}, function(err, db) {
  db.put('hello', 'world', function (err, node) { } )
})

API

var multi = multihyperdb(opts)

Create a new MultiHyperDB. Stores info about multiple hyperdbs in a master hyperdb.

Options include:

{
  path: './db' // Path to store the databases in
  masterPath, dbPath // Set basepath for master databases and child databases manually
  dbOpts // default hyperdb opts for child databases
  storage // callback to return a random-access-storage (see below)
}

multi.createDB(opts, meta, cb)

Create a new hyperdb. opts are regular hyperdb opts (they override the global dbOpts). meta may have any JSON to be stored in the master hyperdb for this child db. cb will be called with (err, db) after the database is ready.

multi.addDB(key, opts, meta, cb)

Add a hyperdb with key key. Other options as in createDB.

multi.dropDB(key, opts, cb)

Drop database key from being managed in this MultiHyperDB. Pass {delete: true} as opts to physically delete the database from disc.

multi.each(callback)

Execute a callback for each database. callbacks parameters are (db, key, meta).

multi.createReadStream(prefix)

Get a combined read stream on all child databases. The on('data' callback receives an object with properties node (the node as returned from a regular hyperdb read stream, with key and value properties) and dbKey (the key of the database).

multi.getDB(key)

Get a database by key.

multi.getDBbyProperty(prop, value, [single])

Get a database by meta property. If single is true, only the first matching database is returned.

Custom storage

By default, both master and child dbs are created with random-access-file storage in the path(s) configured via opts. Alternatively, pass a function as opts.storage.

opts.storage = function(master, key, destroy, cb) {
}

If destroy is false, return a random-access-storage for either master (if master is true) or the child database with key key. If destroy is true, destroy (delete) the child database with key key and call the callback cb.

Syncing and sharing

... is as simple as


var multi = require('multihyperdb')
var hyperdiscovery = require('hyperdiscovery')

var Multi = multi({path: './db1'})

// Create some databases or add existing keys.

// Two-way sync them all!
Multi.each(function(db) {
  hyperdiscovery(db, {live: true})
})

Try it out with example-cli.js:

$ node example-cli.js db1 create myfirstdb
db created with key: d7f69b22386fdc7751fb26e6a458a45c1a5d369525ac0e428eaf0331f59ff0e1

$ node example-cli.js db1 write myfirstdb hello world
Wrote node: Node(key=hello, value='world', seq=0, feed=0))

$ node example-cli.js db1 share


# In another terminal or on another computer

$ node example-cli.js db2 add remotedb d7f69b22386fdc7751fb26e6a458a45c1a5d369525ac0e428eaf0331f59ff0e1 
$ node example-cli.js db2 share

# wait, then abort

$ node example-cli.js db2 read
Node(key=hello, value='world', seq=0, feed=0))

# This was synced from db1.myfirstdb !