An abstract-leveldown implementation that wraps another store to encode keys and values.
Introduction
Stores like leveldown can only store strings and Buffers. Other types, though accepted, are serialized before storage, which is an irreversible type conversion. For a richer set of data types you can wrap such a store with encoding-down. It allows you to specify an encoding to use for keys and values independently. This not only widens the range of input types, but also limits the range of output types. The encoding is applied to all read and write operations: it encodes writes and decodes reads.
Many encodings are builtin courtesy of level-codec. The default encoding is utf8 which ensures you'll always get back a string. You can also provide a custom encoding like bytewise - or your own!
Usage
Without any options, encoding-down defaults to the utf8 encoding.
const levelup = require('levelup')const leveldown = require('leveldown')const encode = require('encoding-down')const db = levelup(encode(leveldown('./db1')))db.put('example', Buffer.from('encoding-down'), function (err) { db.get('example', function (err, value) { console.log(typeof value, value) // 'string encoding-down' })})
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.