Tutorials for Firebase Cloud Firestore

This article shares short introduction of Firebase Cloud firestore.

What is firebase

Firebase is the mobile development platform acquired by Google in 2014. Their mission is "helps mobile and web app teams succeed".

The functions of firebase include:

  • Authentication
  • Cloud Database
  • Cloud Storage
  • Analytics
  • Static file hosting
  • Push Notification
  • Machine Learning Toolkit
  • and many more...

What is Cloud Firestore

The Cloud Firestore is NoSQL based cloud database of firebase. It has mainly 3 characteristic:

  1. No SQL based (ref)
  2. Real-time sync (ref)
  3. Transactional (ref)

There is another database called "Realtime Database" which is old version of Firestore. Basically, Firestore is better.

Pseudo code of Firestore in TypeScript


import firebase from 'firebase/app'
import 'firebase/firestore'
import { FirebaseFirestore } from '@firebase/firestore-types'
const db: FirebaseFirestore = firebase.firestore()

Store data to Firestore

const collectionRef: CollectionReference = db.collection(collectionName)
await collectionRef.doc(documentId).set({
    key: value

Update data of Firestore

await db.collection(collectionName).doc(documentId).update({
  key: value

Get data from Firestore

const collectionRef: CollectionReference = db.collection(collectionName)
const snapshot: DocumentSnapshot = await collectionRef.doc(documentId).get()
const data = snapshot.data()

How much does it cost

The cost of Firestore is calculated based on "The number of Read/Write/Delete Operations", "Storage amount", and Network band-width amount. Additionally, Firebase pricing plans cost. But we can do so much things at Free plan!

How to Start

tag: firestore
Last Updated: 6/22/2019, 7:51:33 AM