Cloud Firestore

From Coders.Bay Wiki
Jump to navigation Jump to search

What is Cloud Firestore?[edit]

Introduction to Cloud Firestore[edit]

Cloud Firestore is a flexible, scalable, Document-Orientated NoSQL Cloud-Database from Google.

It is part of the Firebase-System, which is a Backend-Toolset, which includes Cloud Firestore, a Realtime Database, Authentication mechanism and other Cloud-Functions for your Apps.

The Cloud Firestore-DB stores your Data in Collections, which has a Document for each Element you want to store in your Database - each Document is very similar to a JSON. The huge advantage of a System like this is that you can store different Datas for each Object and you don't have null-Values there.

It also is a solution for you, if you want to create real serverless apps that can work if the client is offline.

Also, there are a lot of tutorials and examples on the Firebase-page and all over Youtube so if you might face problems using it, you can simply find a solution.

Key capabilities[edit]

Flexibility: The Cloud Firestore data model is made for flexible, hierarchical data structures. You store your Data in Documents that are organized in collections and can have complex, nested objects and even subcollections.

Expressive querying: Querys in Cloud Firestore can be used to retrieve individual, specific documents or to retrieve all documents of a collection. There is the possibility to have multiple, chained filters and combine filtering and sorting. Because the're indexed by default, each query performance depends only on the size of your result and not on the size of your Database

Realtime updates: Like the Realtime-Database from the Firebase-System the Cloud Firestore is designed to have realtime updates and make simple, one-time fetch queries efficiently

Offline Support: The data, that your app uses actively are fetched and even if the device is offline, you can read, write, listen to and query data. If the device is back online, the Cloud-Firestore synchronites any local changes with the cloud.

Designed to scale: With Cloud Firestore you get the best of Google Cloud's infrastructure: automatic multi-region data replication as well as strong consistency guarantees. It is designed to handle even the toughest database workloads of the biggest apps in the world.

When to use a DB like Firebase?[edit]

The downside: You don't have the foreign keys from a relational database and if you e.g. want to store a User to a Post, you need to store the data multiple times, so if you need to change it, you need to change it in many places.

So the real best option to use is when you need fast querys but do not change data often - you can get the benefit of fast and big queries, but have more work when you need to change a Username or something that is saved in many Documents

What languages are supported by Firestore?[edit]

Each language can use Firestore, for example you can simple create a Map in Java and then store the data in Firestore. You can even write a program in C or Object-C and use it.

Even more, if you use React, AngularJS, Flutter or Backbone.js, are among the 53 Frameworks that integrate with Firebase.

How to use[edit]

Which big companies do use Cloud Firestore[edit]

I think the biggest example to point out is Twitch that uses it, but there are also GitBook, Patreon, Trustpilot, Instacart, Alibabatravels and much more. If you are interested, there is a Link to stackshare

"Install" Firebase[edit]

To install Firebase, you just need to go to the Firebase console on your browser and create the Firebase of your need - there you can set where it is (4 Locations in europe, even more in Northamerice, Southamerica, Asia and also in Australia.

Get an instance on Java[edit]

Firestore Instance.png

If you want to see the example in other languages like Python, C++ or PHP, simply go here

Create your first collection and data[edit]

Firestore createData.png

Read data[edit]

On one site, you can simply go to your Firebase Console and show the data there, or you read it with Java:

Firestore read.png


You can save queries as Object in Java, for example you can retrieve a specific data and directly print it with only one function.

This is an example:

Firestore query.png

Secure the data[edit]

To secure your data, you can give permissions to your users. This settings are made in the Firebase Console

For more information about the use, pricing etc please visit the Firestore Documentation

Made by Markus K.