0

I am working on a personal project to recreate the news feed of Facebook. So what I am trying to do is to recreate the scenario where when the user goes to the news feed, the user gets posts of everyone he follows only. Is there any way to run a query like that using the Firebase real-time database using an of "followings". This is the demo structure of the database

I can successfully generate single users posts in the android studio app using snapshot and recycler view.

yuri yuna
  • 25
  • 4

1 Answers1

1

If you're asking whether you can get posts from multiple userUID values with a single query, that is not possible.

If you're asking whether you can pass a list of postUID values to retrieve, that is also not possible.

In both cases the solution is to execute a separate query/read operation for each of the values, and merge the results in your application code. This is not nearly as slow as you may think, since Firebase pipelines the requests over a single web socket connection - which is quite efficient. For more on this, see Speed up fetching posts for my social network app by using query instead of observing a single event repeatedly

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Dear @Frank, So you mean, I would have to query and append? Do you know any way to do so in Android studio(JAVA)? Like how do I append the result? – yuri yuna Oct 10 '21 at 19:12
  • 2
    Are you asking [how to join two lists in java?](https://www.google.com/search?q=how+to+join+two+lists+in+java) Or maybe even better: [how to merge two asynchronous lists in java.](https://www.google.com/search?q=how+to+merge+two+asynchronous+lists+in+java) – Frank van Puffelen Oct 10 '21 at 19:54
  • Yes, sort of. Also is there any way to sort the list comparing the timestamp? – yuri yuna Oct 11 '21 at 08:19