willhlaw / node-firestore-backup-restore

Google Firebase Firestore backup and restore tool
91 stars 24 forks source link

sorting the keys before writing documents to file #23

Closed chaoranxie closed 6 years ago

chaoranxie commented 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, following code is all that's needed

var stringify = require('json-stable-stringify');
fileContents = stringify(documentBackup, { space: 2 });

instead of

fileContents = JSON.stringify(documentBackup, null, 2);
willhlaw commented 6 years ago

Good idea. And that library is by @substack and looks good to me. I'll accept a PR for this.

chaoranxie commented 6 years ago

created the PR just now https://github.com/willhlaw/node-firestore-backup-restore/pull/25

willhlaw commented 6 years ago

@chaoranxie Thanks again for the PR. It was accepted and the new --stable option was published as 1.3.0.