-1

Once a query data from firebase, can we then query it once more on the snapshot level?

I basically want to query my data twice 1- Genre: “Arts & Humanities” 2-Timestamp

Just brainstorming ideas since we can’t query twice. I’m also limited on how I can structure my data

1 Answers1

0

Once you execute a query against the Firebase Realtime Database, you get a DataSnapshot that contains all the data that matches the query. So while you can continue to filter the data in your Swift code, you cannot execute another query against the snapshot. You'll instead have to loop through the data, and filter it yourself.

Note however that might be able to meet your query needs with a single query. Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For example, you could add a property "Genre_Timestamp": "Arts & Humanities_1581309158055" and order/filter on that. For another example of this and other approaches, see my answer here: Query based on multiple where clauses in Firebase

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807