Giter Site home page Giter Site logo

level-pathwise's Introduction

level-pathwise

Turn a leveldb into one huge object of arbitrary size! Efficiently and atomically update and read parts of it!

build status

Example

var Pathwise = require('level-pathwise');
var level = require('level');

var store = new Pathwise(level('db'));

// insert an object on the root level

store.put([], {
  foo: {
    bar: ['beep', 'boop'],
    baz: 'bleep'  
  }
}, function(err){});

// read it out

store.get([], function(err, obj){
  // => {
  //      foo: {
  //        bar: ['beep', 'boop'],
  //        baz: 'bleep'  
  //      }
  //    }
});

// read only a subsection of the object,
// like data.foo.bar

store.get(['foo', 'bar'], function(err, obj){
  // => ['beep', 'boop']
});

// extend an object,
// like data.foo.key = 'value'

store.put([], {
  foo: {
    key: 'value'
  }
})

// read the direct children of a path

store.children(['foo'], function(err, children){
  // => ['bar', 'baz']
});

// remove some data,
// like delete data.foo.baz

store.del(['foo', 'baz'], function(err){});

// perform several updates in one atomic step,
// like data.i.said.what = 'what'; delete data.foo;

store.batch([
  { type: 'put', path: [], data: { i: said: { what: 'what' } } },
  { type: 'del', path: ['foo'] }
], function(){});

Installation

$ npm install level-pathwise

API

Pathwise(db)

Instantiate a new pathwise store, using db.

#put(path, object[, opts], fn)

Store object at path.

Options:

  • batch: LevelUP batch object to use

#get(path, fn)

Get the object at path with all its children.

#del(path[, opts], fn)

Delete the object at path with all its children.

Options:

  • batch: LevelUP batch object to use

#children(path, fn)

Get the direct children of path.

#batch(ops, fn)

Execute multiple get and del operations in one atomic batch. ops is an array with objects of type

  • { type: 'put', path: path, data: data }
  • { type: 'del', path: path }

License

MIT

level-pathwise's People

Contributors

greenkeeper[bot] avatar juliangruber avatar mokpi 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

kvnneff iq-scm

level-pathwise's Issues

problem with level

Level-Pathwise does not work properly with level (version 3.0.0) . The test with memdb is successful, but fails with level. The get method returns always an empty object. Although previously inserted with put objects.

docs

proper wording, motivation, examples, etc

Collision Handing / Update Method

Just curious if I could get a quick answer to this one, what happens if I were to do something like db.put([], { index: {} }, cb) if there are already existing keys inside of the index object?

I'll be playing with it in an upcoming project, so I'll probably answer my own question shortly, but it's probably worth documenting info about how collision / updates are handled.

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.