willhlaw / node-firestore-backup-restore

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

Add feature to delete all documents in all collections or to replace when restoring #7

Open willhlaw opened 6 years ago

willhlaw commented 6 years ago

When migrating data or backing up and restoring data, we want to completely replace the database when restoring the data. So there should be an option to clear a firestore database. The option should be made clearly available as a standalone operation and an option when restoring data from disk or from another firestore instance.

The idea is from this comment by @MrDrProfX.

@pmarconi Awesome. Something I'm wondering about is what will happen to new documents/fields and collections that have been added since the backup. Two options could be:

Replace: delete the entire target firestore db and completely replace it with the disk backup Merge: merge the target firestore db with the disk backup Perhaps this could be an additional command line argument. Personally I would rely on the merge for my project.

See reference docs for deleting in batch: https://firebase.google.com/docs/firestore/manage-data/delete-data#collections

Checklist

Optional