Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
LevelDB JSON Wrapper
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
.npmignore
.travis.yml
README.md
index.js
package.json
test.js

README.md

level-json Build Status

LevelDB wrapper to avoid repeating encoding fields for just JSON

Install

$ npm install level-json

Usage Example

io = require('level-json')('./db')

io.set('foo', { foo: 123, bar: 456 }, function (error) {
  if (error) throw error

  io.get('foo', function (error, foo) {
    if (error) throw error

    foo
    // => { foo: 123, bar: 456 }
  })
})

API

Call level-json with a directory path to establish new LevelDB connection:

io = require('level-json')('./data')

A wrapper function with following methods will be returned:

  • del
  • get
  • set
  • batch
  • createReadStream
  • createWriteStream
  • destroy
  • close
  • isClosed
  • isOpen

The wrapper function can be called for getting and setting values like below:

io('foo', { foo: 123 }, function (error) {

  io('foo', function (error, foo) {

    foo
    // => { foo: 123 }

  })

})
Something went wrong with that request. Please try again.