Closed chaoranxie closed 6 years ago
is there any way to sort the keys before writing the documents to file? Basically, I am committing the backup files to version control but every time I do a new backup it shows all the documents are changed.
From what I can tell, you might need to update this line https://github.com/steadyequipment/node-firestore-backup/blob/master/dist/firestore.js.flow#L117 to use something like https://www.npmjs.com/package/json-stable-stringify though I have not use the package myself and don't know if it is as simple as change one line of code.
Thanks
I tested the following code which seems to be what's needed
var stringify = require('json-stable-stringify'); fileContents = stringify(documentDataToStore, { space: 2 });
Great idea!
is there any way to sort the keys before writing the documents to file? Basically, I am committing the backup files to version control but every time I do a new backup it shows all the documents are changed.
From what I can tell, you might need to update this line https://github.com/steadyequipment/node-firestore-backup/blob/master/dist/firestore.js.flow#L117 to use something like https://www.npmjs.com/package/json-stable-stringify though I have not use the package myself and don't know if it is as simple as change one line of code.
Thanks