0

I'm producing a project with Firebase Realtime Database.

I have to post pictures with timestamp, latitude and longitude, and search for pictures in a radios from my position, ordered by timestamp and with the value of the timestamp 1 days from now.

Is Firebase Realtime Database + Geofire right for me?

I cannot figure out how to make queries.

Thank you!

1 Answers1

2

The Realtime Database only supports one dimensional queries. So, if you did want to use the RTDB, you'd need a two-stage query.

  1. geoquery all the pictures in your given center/radius.
  2. for each of these pictures, query all the data for that picture.
  3. Once the data arrives for all the pictures, filter/sort client side.

RTDB structure would be something like:

pictures/{pic_id}: {
  timestamp:,
  name:
  [,...]
},
geofire_pictures/{pic_id}: <geofire data>

With that said, I think RTDB would be a fine choice if you expect your result set sizes to be managable. If you need to scale, I would suggest waiting for Firestore's geoquery functionality.

Vincent
  • 1,553
  • 1
  • 11
  • 21