1
votes

I have a collection of groups and a collection of users, each user document has a collection of ids to the group he has joined. each group id document has one field (timestamp) to mark when a user joined a group. I want to get the list of groups the user has joined in ordered by timestamp descending. First I am getting the groups ids from the sub collection inside user document and they are ordered by timestamp, Then, I am using whereIn() to get the groups objects from the groups top level collection by passing 'groupsIds' ArrayList.

Here is the problem, resulted documents from whereIn() are randomly ordered. I want them to be ordered according to 'groupsIds' list. Can firestore do that for me ? Or I will have to do this myself ?

1

1 Answers

0
votes

If you can't tell Firestore how to sort the documents using orderBy, you're going to have to sort the documents yourself. And in this case, you are going to have to do that.