Last active
August 29, 2015 14:11
-
-
Save sethvincent/288bf2e2ca569bc6c06d to your computer and use it in GitHub Desktop.
level-dat & level-spaces experiment
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 ldat = require('level-dat'); | |
var spaces = require('level-spaces'); | |
var level = require('level-party'); | |
var main = level('./db'); | |
var dat1 = ldat(spaces(main, 'dat1'), { valueEncoding: 'json' }); | |
var dat2 = ldat(spaces(main, 'dat2'), { valueEncoding: 'json' }); | |
dat1.get('huh', function (err, value) { | |
if (value) return console.log(JSON.parse(value).msg); | |
dat1.put('huh', JSON.stringify({ msg: 'can i do this?' }), function (err) { | |
if (err) console.log(err); | |
}); | |
}); | |
dat2.get('wooo', function (err, value) { | |
if (value) return console.log(JSON.parse(value).msg); | |
dat2.put('wooo', JSON.stringify({ msg: 'i can do this!' }), function (err) { | |
if (err) console.log(err); | |
}); | |
}); | |
dat1.createChangesReadStream().on('data', function (data) { | |
console.log('dat1: ', data); | |
}); | |
dat2.createChangesReadStream().on('data', function (data) { | |
console.log('dat2: ', data); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment