Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var lvlup = require("levelup")
var db = lvlup("/tmp/source_db")
var batch = 10000
function makeBatch(num) {
var b = []
for (var i = num; i < num + batch; i++) {
b.push({type: "put", key: "z~" + i, value: Math.random()})
}
return b
}
function populate(start) {
db.batch(makeBatch(start), function (err) {
if (err) throw err
start += batch
if (start < 1000000) {
console.log(start)
populate(start)
}
})
}
populate(0)
var lvlup = require("levelup")
var src = lvlup("/tmp/source_db")
var tgt = lvlup("/tmp/target_db")
var start = Date.now()
src.createReadStream()
.pipe(tgt.createWriteStream()
.on("close", function () {
console.log("Done, in %s", Date.now() - start)
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.