Query data in multiple collections

前端 未结 3 1646
一向
一向 2021-01-28 22:09

I am developing a chat app using Firebase Firestore. I have a collection for room chat and another one for user info. How can I retrieve user data when I listen Room snapshot.

3条回答
  •  春和景丽
    2021-01-28 22:32

    You may not be able to query two collections at the same time but you can still get user details. I did the same thing when fetching post comments. What you need to do is have a UsersAdapter class that extends firestore recycler adapter class and do the same with the rooms collection. The firestore recycler adapter class listens to changes to data. So when you receive the data in the online method in the adapter class, u can get the rest of the data there before it's loaded to the recycler view.

    I hope that makes sense

提交回复
热议问题