Skip to content

Instantly share code, notes, and snippets.

@javalnanda
Created January 29, 2020 09:52
Show Gist options
  • Select an option

  • Save javalnanda/79dfd0c9796bbcced157b3dae62c6e0d to your computer and use it in GitHub Desktop.

Select an option

Save javalnanda/79dfd0c9796bbcced157b3dae62c6e0d to your computer and use it in GitHub Desktop.
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