Javatpoint Logo
Javatpoint Logo


Firebase Firestore

We have two options with Firebase, i.e., Firebase Real-time Database, which we learned in our previous section and Cloud Firestore. Cloud Firestore is newer, but it is not replacing the Firebase Real-time Database. Cloud Firestore is a flexible as well as scalable NoSQL cloud database. It is used to store and sync data for client and server-side development. It is used for mobile, web, and server development from Google Cloud Platform and Firebase. Like the Firebase Real-time Database, it keeps syncing our data via real-time listeners to the client app. It provides offline support for mobile and web so we can create responsive apps that work regardless of network latency or Internet connectivity.

Cloud Firestore also provides seamless integration with Google Cloud Platform products and other Firebase, including cloud functions.

Firebase Firestore

Key capabilities


The Firestore data model supports a flexible, hierarchical data structure. It stores our data in the document, which is organized into a collection. In Firestore, the documents can contain complex nested objects rather than sub-collections.

Expressive querying

In Firestore, we can use queries for retrieving specific, individual documents or for retrieving all the documents in a collection that match our query parameters. Our queries combine filtering and sorting and can include multiple, chained filters. The query performance is proportional to the size of our result set because queries are indexed by default.

Real-time updates

Firestore is quite similar to Firebase Realtime Database. Firestore also uses data synchronization for updating data on any connected device. It is designed for making simple one time fetch queries efficiently.

Offline Supports

Cloud Firestore enables us to make a cache of the app data, which it is actively using. This makes the app to read, write, query, and listen to the data even when the device is offline. When the device comes in an online mode, Cloud Firestore synchronizes the local changes back to it.

Designed to scale

Cloud Firestore provides us the best infrastructure of the Google Cloud Platform: automated multi-region data replication, atomic batch operations, strong consistency guarantees, and real transaction support. We designed Cloud Firestore for handling the toughest database workloads from the world's largest apps.

How does it work?

Cloud Firestore, a cloud-hosted, NoSQL database, is accessed directly through the native SDK by our iOS, Android, and web apps. In addition to REST and RPC APIs, Cloud Firestore is also available in native Node.js, Java, Python, and Go SDKs.

Firebase Firestore

After Cloud Firestore's NoSQL data model, we can store data in documents that have field mappings for values. The documents are stored in a container called collections. These containers are used to organize our data and create queries. There are different data types, from simple string and numbers to complex nested objects, supported by documents. We can also create sub-collection within a document and create a hierarchical data structure that scales to the growth of our database. The Firestore data model supports whatever data structure works best for our app.

Additionally, the query in Cloud Firestore is expressive, efficient, and flexible. The shallow queries are created to retrieve data at the document level without the need to retrieve the entire collection or any nested subdivision. Add sorting, filtering, and limits for our queries or cursors to index the result. Add a real-time listener to our app for keeping the data running. Every time it is updated without recovering our entire database.

Adding real-time listeners to our app informs us with a data snapshot whenever our customer apps are changing data, only getting new changes.

For protecting our data access in Cloud Firestore, Firebase authentication, and Cloud Firestore security rules are used for Identity and Access Management (IAM).

Features of Firestore

There are the following features of Firestore:

Firebase Firestore


For data, Cloud Firestore has built-in security access controls. It enables simple data validation via a configuration language.

Datastore mode

Cloud Firestore supports the Datastore API. We don't need to make any changes to our existing Datastore apps. We can expect similar performance characteristics and pricing with the added benefit of strong stability.

Automatic upgrade

The Cloud Datastore database will be upgraded shortly and natively after the GA release of Cloud Firestore. No code changes are required, and there is no downtime for our app.

ACID transaction

Cloud Firestore has support for transactions, so if any operations in the transaction fail (and cannot be withdrawn), then the entire transaction will fail.

Multi-region replication

With the help of automatic multi-region replication and strong stability, our data is safe and available, even when disasters strike.

Powerful query engine

Cloud Firestore allows us to run sophisticated queries against our NoSQL data without any degradation in performance. This gives us more flexibility to structure our data.

Built for cloud-native applications

Mobile and web applications are included by the typical workloads which collaborate with the multi-user, retail product catalogs, IoT asset tracking, social user-profiles and activity, communications, and gaming leaderboards.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA