Created
January 29, 2020 09:52
-
-
Save javalnanda/79dfd0c9796bbcced157b3dae62c6e0d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fs = require('fs'); | |
| console.log("\n *START transformation* \n"); | |
| var content = fs.readFileSync("db.json"); | |
| var json = JSON.parse(content); | |
| var docs = json.rows; | |
| var newDocs = new Array(); | |
| docs.forEach(function(doc) { | |
| var innerdoc = doc.doc; | |
| delete innerdoc._rev; | |
| newDocs.push(innerdoc); | |
| }); | |
| var newJson = new Object(); | |
| newJson.docs = newDocs; | |
| var newContent = JSON.stringify(newJson) | |
| fs.writeFile('db_u.json', newContent, 'utf8', function(err) { | |
| if (err) throw err; | |
| console.log('complete'); | |
| }); | |
| console.log("\n *DONE transformation!* \n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment