How to use Cloud Firestore in a non-realtime fashion?

I've really been investing a lot of time integrating Firestore into my new apps and I'm loving it so far. One thing I noticed is it's very much "realtime" as it touts. This is awesome for writing chat apps, etc, but for non "realtime" features of those apps, it seems kind of excessive to use the Observable pattern for that as you're really probably only attempting to grab a list (not an add, update or delete event) or even a single item and doing the map on a snapshotChange gets a little repetitive in this case as well.

Is there a suggested or recommended way to use Firestore in an almost "RESTful" manner? I'm using the AngularFire2 library if that matters at all. Is it just suggested to use the firestore methods from the firebase npm packages?

1 answer

  • answered 2018-01-11 21:14 Tom Bailey

    I think you might be confusing Firebase Realtime Database and Firebase Firestore.

    Firebase Realtime Database is very much as you describe in that it is expected you will subscribe to a stream of updates for the data you are interested in. Functionality is provided for "one-time" reads but the product name, documentation and samples often portray real-time scenarios.

    Cloud Firestore, on the other hand, does not make these assumptions but still provides the option of real-time stream updates or "one-time" reads.

    For deciding between the 2, you should read Google's own document on what they believe the suitability of each is.

    If you decide to use Firestore, a sample "one-time" read is documented here.