codediodeio / firestore-migrator

:bullettrain_side: A CLI utility for moving data to and from Cloud Firestore
https://angularfirebase.com/lessons/import-csv-json-or-excel-to-firestore/
317 stars 94 forks source link

Batch deletes of a collection #15

Open SogoGolf opened 5 years ago

SogoGolf commented 5 years ago

hi there, first a huge thank you for this great migrator lib. Has been massive time saver.

Is it possible to use firestore-migrator to do a batch delete of a collection, prior to running it for an upload ?

or is there a flag i can set so that if i re-run an upload to a collection, it will overwrite, not append the data (documents) to the collection ?

stildalf commented 5 years ago

Good point, as it is now uploaded documents replace existing ones with the same ID, and there's the --merge option. But there's no way to prune excess documents or delete an entire collection prior to import - analogous to sql's TRUNCATE TABLE.

Have you thought of the best way to implement such a feature? Should we use a flag per collection, or every collection imported. Or perhaps a new cli option, such as --truncate path/to/collection.

SogoGolf commented 5 years ago

i think a command line argument would be perfect. for example:

fire-migrate import --replace test.INDEX.csv myCollection

samiq commented 5 years ago

if this is already fixed for, can someone close this ticket, I think it's important to keep this tidy to not give the wrong impression to people looking around this lib