Saves JSON to your LevelDB
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
LICENSE
README.md
index.js
package.json
test.js

README.md

level-set

Saves JSON to your LevelDB. Converting your JSON to LevelDB key-value pair data structure.

Install

npm install level-set
var LevelUp = require('levelup'),
    LevelSet = require('level-set');

var db = LevelUp('./testdb');

LevelSet(db);

Set JSON object

var person = { name: 'Maiah', occupation: 'Ninja' };
db.set('/', person, function (err) {
  if (!err) console.log('Saved person under root path');
});

This will put key-value pairs LevelDB data structure at the root path.

name = Maiah
occupation = Ninja

You can also save any valid JSON structure.

var person = {
  name: 'Maiah',
  occupation: 'Ninja',
  tools: {
    lang: 'js'
  }
};

db.set('/', person, function (err) {
  if (!err) console.log('Saved person under root path');
});

This will put key-value pairs LevelDB data structure at the root path.

name = Maiah
occupation = Ninja
tools/lang = js

You can also specify a path other than the root.

var person = { name: 'Maiah', occupation: 'Ninja' };
db.set('/person', person, function (err) {
  if (!err) console.log('Saved person object');
});

This will put key-value pairs LevelDB data structure at the person path.

person/name = Maiah
person/occupation = Ninja

License

MIT