Firebase Firestore多文档传递

时间:2019-03-05 18:14:05

标签: android firebase google-cloud-firestore

我有一个关注其他用户的用户。考虑uid1,uid2,uid3。现在,我只想从这些用户ID加载帖子。我只能使用一个Uid。这是我的代码:

 Query firstQuery=firebaseFirestore.collection("Timeline").document(userId).collection("Posts").orderBy("timestamp",Query.Direction.DESCENDING);
        firstQuery.addSnapshotListener(getActivity(),new EventListener<QuerySnapshot>() {
            @Override
            public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {

                for (DocumentChange doc : documentSnapshots.getDocumentChanges()) {
                    if (doc.getType() == DocumentChange.Type.ADDED) {

                        String blogPostId=doc.getDocument().getId();


                        BlogPost blogPost = doc.getDocument().toObject(BlogPost.class).withId(blogPostId);
                        blogList.add(blogPost);
                        blogRecyclerAdapter.notifyDataSetChanged();
                    }
                }


            }
        });

如何将所有userId存储在集合中,并将其传递给集合。 注意:这是新手

0 个答案:

没有答案
相关问题