FlutterFlow Docs
Search…
Firestore Database
Firestore Database is a product from Google's Firebase. It's a flexible, scalable, NoSQL cloud database. It allows you to store your app data and uses realtime listeners to keep the data in sync. It works well in all situations regardless of your internet connectivity.
Firestore Database offers the following features:
  • Flexibility: It allows you to store your data in documents that are organized into collections. This approach allows you to have multiple documents (inside the same collection) that might not have the same structure.
  • Querying: You can form a query to get specific documents or to retrieve all the documents in a collection.
  • Realtime: Firestore database helps you achieve data synchronization to update data on any connected device.
  • Offline: You can write to the database even when offline. When the app is not connected to the internet, the data gets stored in the local device, and when the device comes back online, the data gets synced to the cloud Firestore database.
  • Scaling: Firestore database runs on Google's infrastructure. It provides automatic multi-region data replication, strong consistency guarantees, atomic batch operations, etc.
Let's understand the Firestore database (A NoSQL Database) more in detail.

What is NoSQL Database

The NoSQL database is a schema-less database. That means the data is not stored in the table format. You actually don't have any restriction on how you store your data. The Firestore database uses the collection and document model to store the data.
For example, each user data is stored in a document and such multiple documents are organized into a collection.
As you can see in the figure above, the documents inside the collection may or may not have the same fields. This allows you to introduce the new field for the new document without having to worry about adding the field for older documents.

Structuring the Database

Firestore uses collection, documents, and fields to structure the database.
  • Collection: A Collection is simply a set of Documents.
  • Document: A Document is a record that contains the Fields. The names of documents within a collection are unique.
  • Fields: The key-value pair inside the document are called Fields. Field can contain the value for various data types such as strings, numbers, boolean, and so on.
To structure the database that allows users to comment on a post, create collections as comments, posts, and users. While adding the comment document, add two additional reference fields that uniquely identify the post and user.
To retrieve the results, you can use the Build Firebase Query section (Backend Query tab) inside your FlutterFlow project.
​MongoDB, Cassandra, ElasticSearch are the other No-SQL database solutions that exist in the market.

Rules

Here are some rules to create a Firestore database:
  • Collection can only contain Documents.
  • Your Document should be less than 1MB in size.
  • The root of your Firestore database only contains collections.

Learn more

Learn more about Firestore Database here.
If you are a visual learner, you can check out the video here.
Last modified 1mo ago