webscopeio / react-firestore-connect

HOC for React components which maps collections / documents from firestore into react components props.
18 stars 3 forks source link

Feature request: Maps of references #1

Open loicnico96 opened 6 years ago

loicnico96 commented 6 years ago

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,
)
Olovorr commented 5 years ago

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