Giter VIP home page Giter VIP logo

subhyperdb's Introduction

SubHyperDB

Split a HyperDB into namespaces or sections. Each SubHyperDB may have a different value encoding.

Usage

var hyperdb = require('hyperdb')
var sub = require('subhyperdb')

var db = hyperdb('./db', {valueEncoding: 'binary'})

var sub1 = sub(db, 'sub1', {valueEncoding: 'utf8'})
var sub2 = sub(db, {valueEncoding: 'json'})

sub1.put('hello', 'world', function() {
  sub2.put('hello', {where: 'moon'}, function() {
    sub1.get('hello', function(err, node) {
      console.log('sub1: ' + node.value) // world
    })
    sub2.get('hello', function(err, node) {
      console.log('sub2: ' + JSON.stringify(node.value)) // {where: 'moon'}
    })
  })
})

console.log('Prefix for sub1: ' + sub1.prefix) // prefix for sub1 was set manually
console.log('Prefix for sub2: ' + sub2.prefix) // prefix for sub2 was autocreated

API

var subDb = sub(db, [prefix], [opts])

Create a new sub database.

db has to be a hyperdb instance that was created with a valueEncoding: 'binary' option.

prefix sets the prefix to be used. If not set, a random prefix will be created.

opts So far the only option is valueEncoding.

Public API is a subset of the HyperDB API. Supported methods are:

get, put, del, batch, list, createReadStream, createWriteStream, replicate

Support for more methods (e.g. createDiffStream, createHistoryStream) is TODO.

License

MIT

subhyperdb's People

Contributors

frando avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.