Last active
August 29, 2015 13:57
-
-
Save stdarg/9588146 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var levelup = require('level') | |
var options = { | |
keyEncoding: 'binary' | |
} | |
//var key = 'name' | |
var key = 100 | |
// 1) Create our database, supply location and options. | |
// This will create or open the underlying LevelDB store. | |
levelup('./mydb', options, function(err, db) { | |
if (err) throw err | |
// 2) put a key & value | |
db.put(key, 'LevelUP', function (err) { | |
if (err) return console.log('Ooops on put!', err.message) // some kind of I/O error | |
// 3) fetch by key | |
db.get(key, function (err, value) { | |
if (err) return console.log('Ooops on get!', err.message) // likely the key was not found | |
// ta da! | |
console.log(key + ' = ' + value) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment