0

I'm fetching from the Firebase Cloud database all the users and I want to exclude one user (that current logged in users). The code:

Query usersQuery = fireDB.collection("users").orderBy("full_name", Query.Direction.ASCENDING);
final FirestoreRecyclerOptions<User> options = new FirestoreRecyclerOptions.Builder<User>().setQuery(usersQuery, User.class).build();
usersAdapter = new NewMessageUsersAdapter(options,getActivity());
usersRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
usersRecyclerView.setAdapter(usersAdapter);
usersAdapter.startListening();

I want to exclude connectedUserDocumentRef.getPath() because he cannot write to himself. I know that firebase does not support negation queries (like doesNotContain or !=) so as I understand the change should be after building the query and fetching the data. I also could just ignore it in the onBindViewHolder method of the adapter but then the number of items that are shown is not equal to the getCount. How can I do it?

vesii
  • 2,760
  • 4
  • 25
  • 71
  • I think this **[answer](https://stackoverflow.com/questions/51859652/how-to-exclude-an-element-from-a-firestore-query)** might help. – Alex Mamo Jun 25 '20 at 09:43
  • @AlexMamo Hi, thanks for reply. I saw this topic but they didn't talk about excluding a path or document id unfortunately. – vesii Jun 25 '20 at 09:53

0 Answers0