-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-ID for arrays instead of index #38
Conversation
Thanks for contributing. Can you plain more with an example of this case and update the test file cover this? Thanks, |
When importing data, if you provide an array of objects, they would be imported with their numeric indexes as the key (eg. 0, 1, 2 ..). That's because the import script uses From the docs:
Read: https://cloud.google.com/firestore/docs/manage-data/add-data#add_a_document Also its not recommended to use numeric indexes. This PR fixes that, but I'm not sure how to write tests for that. |
Hi @3zzy, the data structure already has an id for the document from export function. We don't have to regenerate it. Which JSON structure are you trying to import? https://github.com/dalenguyen/firestore-backup-restore/blob/master/test/import-to-firestore.json In the example, the document id is already defined: first-key & second-key. |
@dalenguyen Right, but for when the id needs to be auto generated instead of manually defining it, you could pass an array of objects. So from the above example JSON. Instead of:
We pass:
|
@3zzy you're right. This is another case. I will add the sample file and test cases for supporting this case. |
Lets Firebase generate auto-id's if an array or objects is passed.