0

I'm considering to use Firebase as the server database for the mobile app (iOS). The point is user should be able to:

  1. Work offline with data

  2. Run some queries on data even if it's offline

So I believe the first problem is not a problem anymore as for Firebase implemented the local offline version but what about the second one?

The scenario is: user downloads data when it's online and keep working with loaded data even if it's offline. What does it mean - the app allows user doing search by different criteria, so I have to implement some type of queries on the mobile. I can't figure out though if it's possible with Firebase.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
mimic
  • 4,897
  • 7
  • 54
  • 93
  • Some queries are possible, others won't be. It all depends on your exact use-cases. – Frank van Puffelen Nov 28 '16 at 18:03
  • @FrankvanPuffelen, thanks for you so-quick-response. The queries mostly would be like this "select such and such where fieldA==true and (fieldB between 5 and 45) and fieldC < 30". Is this kind of query possible? – mimic Nov 28 '16 at 18:06
  • Firebase queries can only order/filter on a single property. That has been covered regularly already, so I recommend searching a bit. My de-facto answer is http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Nov 28 '16 at 18:45
  • @FrankvanPuffelen, I saw this post but it's still not clear for me if it can be used on local mobile storage or not, when it's offline and the server database is not accessible. Do you understand what I mean? – mimic Nov 28 '16 at 18:51
  • Yes: you can run queries when you are offline. No: you sometimes cannot run queries in certain situations. Yes: you can query Firebase. No: you cannot query Firebase for multiple values... kinda. Do some searching on that as there are other options. – Jay Nov 29 '16 at 22:19
  • @Jay this sounds weird :( – mimic Nov 30 '16 at 17:16
  • It does but when working with real time databases that can have an offline and online state, there are certain things that you have to account for in code. The query'ing thing is a side note and wanted you to be aware of the limitations. I would suggest crafting a simple app to test. Generate a list in Firebase then query the list online and offline. A lot of it has to do with your use case and how/where/what you are doing with the data and queries. I would suggest posting some sample code and a snippet of your Firebase structure (as text) so we can better advise. – Jay Nov 30 '16 at 19:31
  • @Jay thanks for advice. It make sense but from here https://firebase.google.com/docs/database/ios/offline-capabilities I see it's not really possible to work with offline data. When the phone is offline, the data is gotten from the cache and after restarting app everything is lost. I don't know maybe I understood it wrongly. My scenario must include all the regular operations no matter if it's offline or not. – mimic Dec 01 '16 at 00:37
  • Ah. that's much more clear. The original question simply asked it it was possible to work with offline data and 'run some queries'. – Jay Dec 01 '16 at 18:42

0 Answers0