Socket
Book a DemoInstallSign in
Socket

@nothingness/level

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nothingness/level

Water seeks its own level; without not-water we cannot be wet.

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

@nothingness/level

Minimal / simplistic / incomplete / bad adaptor to connect level to nothingness.

install

npm install --save nothingness @nothingness/level

usage

var ThingerDAO = require('./thinger-dao.js');
var Adaptor = require('@nothingness/level');
var assert = require('assert');

var dao = new ThingerDAO(new Adaptor('./thinger-db'));
var thingy = { type: 'great band' };

// uses Bluebird's .nodeify(), so callback or promise chain are fine
dao.save(thingy, function (err) {
  if (err) throw err;

  dao.findAll(function (err, results) {
    if (err) throw err;

    assert.deepEqual(
      results,
      [{ type: 'great band' }],
      'should only have one item, of type "great band"'
    );

    console.log('round trip succeeded!');
  });
});

API

new Adaptor(pathToLevelDB)

Connect the Adaptor to a LevelDB data directory; assumes that all values will be encoded as JSON.

save(key, value, cb)

Maps to the put function for levelup; assumes that key generation and object preparation is handled elsewhere.

findAll(cb)

Load all of the values in the collection. Override this unless you're only storing one type of value per LevelDB database.

closeDB(cb)

Maps to the close function for levelup.

caveats

This is pre-1.0.0 software, and I'm going to keep iterating on this and nothingness until I have the basic CRUD logic and simple finders worked out for both sides in a way that doesn't make me want to barf. Getting this done in a way that keeps the coupling level right is tricky.

It may take a little while given my other commitments, so don't be surprised if this doesn't go anywhere interesting for a while.

Keywords

nothingness

FAQs

Package last updated on 23 May 2016

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