Cloud Firestore Basics
Read and write realtime data.
What Is Cloud Firestore?
Cloud Firestore is Firebase's flexible, scalable NoSQL database. It stores data as documents grouped into collections.
- A document is a set of key/value fields (like a JSON object).
- A collection is a container of documents.
- Documents can contain subcollections, forming a tree.
Firestore also offers realtime updates and works offline out of the box.
Get the Firestore Instance
Access the database through Firebase.firestore. From there you reach a collection with collection("name") and a specific document with document("id").
References are cheap to create — they describe a location, not the data itself.
import com.google.firebase.Firebase
import com.google.firebase.firestore.firestore
val db = Firebase.firestore
val usersRef = db.collection("users")
val oneUser = db.collection("users").document("abc123")All lessons in this course
- Setting Up Firebase
- Firebase Authentication
- Cloud Firestore Basics
- Push with Cloud Messaging