Firestore
We have two Firebase options to consider: Firebase Real-time Database, which we discussed in a previous section, and Cloud Firestore. Cloud Firestore, while relatively newer, is not intended to replace Firebase Real-time Database but rather to complement it. Cloud Firestore is a versatile and scalable NoSQL cloud database designed for storing and synchronizing data for both client and server-side development. It serves the needs of mobile, web, and server development and is offered through Google Cloud Platform and Firebase. Much like the Firebase Real-time Database, Cloud Firestore employs real-time listeners to keep data in sync with client applications. Additionally, it offers offline support for mobile and web platforms, enabling the creation of responsive applications that function seamlessly regardless of network latency or Internet connectivity.
Cloud Firestore offers smooth integration with various Google Cloud Platform services and other Firebase components, including cloud functions.
Key capabilities
Flexibility
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, you have the ability to employ queries to retrieve either specific individual documents or all documents within a collection that align with your specified query criteria. These queries are versatile, allowing you to incorporate a combination of filtering and sorting, and you can even chain multiple filters together. The efficiency of your query depends on the size of the result set, as Firestore automatically indexes queries 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.
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:
Security
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 empowers us to perform advanced queries on our NoSQL data while maintaining high performance. This enhanced capability provides us with greater flexibility in organizing our data.
Built for cloud-native applications
The common use cases for mobile and web applications involve interactions with multiple users, handling retail product catalogs, IoT asset tracking, managing social user profiles and activities, supporting communication, and maintaining gaming leaderboards.
No comments:
Post a Comment