Last active
August 29, 2015 14:05
-
-
Save fergiemcdowall/843f363165ca5f5ae2d2 to your computer and use it in GitHub Desktop.
How to pipe a file of key-value pairs into levelUP
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
{"key":"john","value":"lennon"} | |
{"key":"paul","value":"mccartney"} | |
{"key":"ringo","value":"starr"} | |
{"key":"george","value":"harrison"} |
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
{ | |
"dependencies": { | |
"level": "*", | |
"JSONStream" : "*" | |
} | |
} |
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 level = require('level'), | |
db = level('./mydb'), | |
JSONStream = require('JSONStream'), | |
fs = require('fs'); | |
fs.createReadStream('backup.json') | |
.pipe(JSONStream.parse()) | |
.pipe(db.createWriteStream({"type":"put"})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As discussed here: Level/levelup#274