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

Bad parsing of arrays of DocumentReferences #110

Open
francescopellegrini opened this issue Jun 12, 2021 · 0 comments
Open

Bad parsing of arrays of DocumentReferences #110

francescopellegrini opened this issue Jun 12, 2021 · 0 comments

Comments

@francescopellegrini
Copy link

Given an exported data as follows:

const data = {
  collection1: {
    docId: {
      refArray: [
        {path:'collection1/document1-ref'},
        {path:'collection2/document2-ref'}
      ]
    }
  }
}

the refArray field gets parsed into 'collection2/document2-ref instead of an array of strings.

This is because the field is completely overridden while looping on the original array.

for (let val of data[collectionName][doc.id][refKey]) {
data[collectionName][doc.id][refKey] = getPath(val)
}

The appropriate way of mapping the array values can be seen in import.ts:

data[ref] = data[ref].map((ref) => db.doc(ref))

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