Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hackergrrl/1dc3caebad2895bb79e6a9d85973b21c to your computer and use it in GitHub Desktop.
Save hackergrrl/1dc3caebad2895bb79e6a9d85973b21c to your computer and use it in GitHub Desktop.
var hyperdb = require('hyperdb')
var json = {
encode: function (obj) {
return Buffer.from(JSON.stringify(obj))
},
decode: function (buf) {
var str = buf.toString('utf8')
try { var obj = JSON.parse(str) } catch (err) { return {} }
return obj
}
}
var fn = '21b2b9ff201b01e6081709d82e6b81a5cf3a68d2cd5f092d0ffec58772642892'
var db = hyperdb(fn, { valueEncoding: json })
db.ready(function () {
db.get('messages/default/787', function (err, node) {
console.log('odd res', err, node)
})
})
@mafintosh
Copy link

This exits because nothing is on the event loop. You need to setup replication to make this work. We do need a wait: true flag tho

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment