0
0
Firebasecloud~30 mins

Why Firestore is Firebase's primary database - See It in Action

Choose your learning style9 modes available
Why Firestore is Firebase's primary database
📖 Scenario: You are building a simple app that stores user profiles. You want to use Firebase's main database service to save and retrieve user data efficiently.
🎯 Goal: Learn how to set up Firestore as the primary database in Firebase and understand why it is preferred over other options.
📋 What You'll Learn
Create a Firestore database instance
Configure Firestore with proper settings
Add a user profile document to Firestore
Retrieve and display user profile data
💡 Why This Matters
🌍 Real World
Apps need a fast, scalable database to store user data and Firestore provides this with easy setup and real-time updates.
💼 Career
Understanding Firestore is essential for Firebase developers building modern web and mobile apps.
Progress0 / 4 steps
1
Create a Firestore database instance
Create a variable called db and set it to the Firestore database instance using firebase.firestore().
Firebase
Need a hint?

Use firebase.firestore() to get the Firestore database instance.

2
Configure Firestore with proper settings
Create a variable called settings and set it to an object with timestampsInSnapshots set to true. Then apply these settings to db using db.settings(settings).
Firebase
Need a hint?

Firestore requires enabling timestamps in snapshots for better date handling.

3
Add a user profile document to Firestore
Use db.collection('users').doc('user1').set() to add a document with name set to 'Alice' and age set to 30.
Firebase
Need a hint?

Use collection and doc to specify where to store the user data.

4
Retrieve and display user profile data
Use db.collection('users').doc('user1').get() to retrieve the document, then access its data with doc.data().
Firebase
Need a hint?

Use get() to fetch the document and data() to read its contents.