react-firebase-hooks icon indicating copy to clipboard operation
react-firebase-hooks copied to clipboard

How to include sub-collection in each item of a collection

Open jaytonic opened this issue 1 year ago • 0 comments

Hi,

I've a collection of items, which have a subcollection.

I currently get the collection like this:

  const [user] = useAuthState(auth);
  const householdsRef = collection(db, "households");
  const queryRef = query( householdsRef, where("participantsIds", "array-contains", user!.uid)  );
  const collectionRef = queryRef.withConverter(householdConverter);
  const [households, householdLoading, householdError, householdSnapshot] =  useCollectionData<Household>(collectionRef);

And I would like to consolidate my households collection with the invites sub-collection.

My understanding is that there is no built-in way of doing this with react-firebase-hooks, but I'm also lost on how to implement this myself, without loosing the real-time update of firebase.

My hope is that somebody already got the same issue and is willing to share its solution with me?

Thanks

jaytonic avatar Dec 31 '23 14:12 jaytonic