I'm trying to figure out how to mimic querying by value with an array, but having issues as the data loses its ordering if each query by value is done individually.
Let's say the database has the following format:
- postID
- userID
- datePosted
And on the client side, I have an array of userIDs: [id1, id2, id3]
I want to sort postID's by datePosted, query by value where the userID equals one of the id's in the array. I then want to query the first 5 posts. So, this should get a total of at most 5 of the most recent posts from those users.
I've read that you are not able to query by value with an array, meaning this would have to be separated into single queries for each userID (such as firebase equivalent to sql where in () suggests). However, if I were to do that, I'd no longer be able to correctly sort by datePosted between posts from different users and would have to download ALL posts to be able to sort and get the first 5.
In essence, I'm trying to accomplish: ref.queryOrderedByChild("datePosted").queryEqualToValue(array, "userID").queryLimitedToFirst(5)
Anyone ran into this kind of problem before? Would appreciate any suggestions!