You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
564 B

4 years ago
var iteratorStream = require('./')
var leveldown = require('leveldown')
var path = require('path')
var db = leveldown(path.join(__dirname, 'db'))
db.open(function (err) {
if (err) throw err
var ops = []
for (var i = 0; i < 1000; i++) {
ops.push({
type: 'put',
key: String(Math.random()),
value: String(Math.random())
})
}
db.batch(ops, function (err) {
if (err) throw err
var stream = iteratorStream(db.iterator())
stream.on('data', function (kv) {
console.log('%s -> %s', kv.key, kv.value)
})
})
})