[go: nahoru, domu]

Skip to content
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

Import script runs collection group query that does not respect collection path in config. #75

Closed
iansmathew opened this issue Oct 12, 2021 · 0 comments · Fixed by #80
Closed

Comments

@iansmathew
Copy link
iansmathew commented Oct 12, 2021

Currently the retrieveDataFromFirestore function of the import script takes the last segment (the last subcollection) of the collection path and runs a collection group query on it.

This leads to documents that are not part of the config collection path being imported into Algolia.
For eg: if my firestore architecture is as follows:

  • Users
    • Records
  • TestUsers
    • Records
  • Admin

And if my collection path stated in the config is users/{x}/records. The import script would currently import records under both Users as well as TestUsers. This is not the expected behavior and could potentially lead to incurring unexpected costs.

Proposed Solution

Perform the collection group query as normal and then filter the results by matching the doc.ref.path to the config.collectionPath. A simple for loop (incremented by 2) matching each collection segment would let you know if the document returned is part of the collection path stated in the config and can continue with the processQuery flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant