🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

level-pathwise

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-pathwise

Nested storage engine

Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

level-pathwise

Work In Progress,

Nested storage engine, basically letting you treat your leveldb like one big object which you can select subjections of.

Example

import Pathwise from 'level-pathwise';
import { default as level } from 'level';

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

store.put([], {
  foo: {
    bar: ['beep', 'boop'],
    baz: 'bleep'  
  }
}, err => {
  store.get([], (err, obj) => {
    // obj => {"foo":{"bar":{"0":"beep","1":"boop"},"baz":"bleep"}}

    store.del(['foo', 'bar'], err => {
      store.get([], (err, obj) => {
        // obj => {"foo":{"baz":"bleep"}}

        store.children([], console.log);
        // => ['foo']

        store.get(['foo', 'baz'], (err, obj) => {
          // obj => "bleep"

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

Installation

$ npm install level-pathwise

API

Pathwise(db)

Instantiate a new pathwise store, using db.

#put(path, object, fn)

Store object at path.

#get(path, fn)

Get the object at path with all its children.

#del(path, fn)

Delete the object at path with all its children.

#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

FAQs

Package last updated on 28 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts