Skip to content

Latest commit

 

History

History
73 lines (58 loc) · 1.28 KB

README.md

File metadata and controls

73 lines (58 loc) · 1.28 KB

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