Home > front end >  Is there anyway to run Firebase realtime database queries with multiple keys?
Is there anyway to run Firebase realtime database queries with multiple keys?

Time:10-12

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.

CodePudding user response:

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

  • Related