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

How can I perform nested collection queries? #95

Open
Glenncito opened this issue Dec 17, 2023 · 0 comments
Open

How can I perform nested collection queries? #95

Glenncito opened this issue Dec 17, 2023 · 0 comments

Comments

@Glenncito
Copy link

I have a collection of conversations. The conversation class contains a property which is a collection of ChatMessages, which contains its own properties.

here is my oode currently:

const conversationRef = query(collection(firestore, `/Conversations`));
const conversationQuery = useFirestoreQueryData(["Conversations", user.data?.uid], conversationRef,{
 idField: "_id",
 subscribe:true
})

function getConversations(){
const snapshot = conversationQuery.data;

if (snapshot){

const conversationArray:ActiveConversation[] = snapshot.map((snapshot) => {
 
 const conversation:ActiveConversation = {
   id: snapshot._id,
   topic: snapshot.topic,
   description: snapshot.description,
   currentMessageInputValue: '',
   chatMessages: [], //want to then query this as well. 
   isLoaded: false,
   members: snapshot.members,
   isConcluded: snapshot.isConcluded,
 }
 return conversation;
})
setActiveConversations(conversationArray);

}
}

useEffect(() => {
getConversations();

 },[conversationQuery.data]);
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

No branches or pull requests

1 participant