react-firestore-connect icon indicating copy to clipboard operation
react-firestore-connect copied to clipboard

Feature request: Maps of references

Open loicnico96 opened this issue 6 years ago • 1 comments

Example usage:

Let's say I have a (dynamic) list of several user IDs that I can give to my components. My components needs additional information that are contained in sub-collections of these users. In this case, I cannot use the current Array functionality because I will not be able to tell which sub-document corresponds to each user (I cannot use the document ID because it will be the ID within the sub-collection, not the ID of the parent user).

export default connectFirestore(
  (db, props) => ({
    subRefs: props.users.reduce((refs, user) =>
      Object.assign(refs, {
        [user.id]: getSubCollectionRef(db, user.id, props.something)
      }), {}),
  }),
  MyComponent,
)

loicnico96 avatar Sep 25 '18 14:09 loicnico96

I will have a look at this by the end of this month, but feel free to create PR if you'd like 🙂

Olovorr avatar Oct 17 '18 09:10 Olovorr