0
0
Firebasecloud~30 mins

Supported data types in Firebase - Mini Project: Build & Apply

Choose your learning style9 modes available
Firebase Supported Data Types
📖 Scenario: You are building a simple Firebase Firestore database to store user profiles for a mobile app. Each user profile will have different types of data such as text, numbers, dates, and boolean values.
🎯 Goal: Create a Firestore document with fields using the supported Firebase data types: string, number, boolean, timestamp, and array.
📋 What You'll Learn
Create a Firestore document data dictionary with specific fields and values
Add a configuration variable for the current timestamp
Use the Firestore data types correctly in the document data
Complete the Firestore document creation code with the correct collection and document ID
💡 Why This Matters
🌍 Real World
Storing user profiles with various data types is common in mobile and web apps using Firebase Firestore.
💼 Career
Understanding supported data types and how to write documents is essential for backend and cloud developers working with Firebase.
Progress0 / 4 steps
1
Create Firestore document data with basic fields
Create a dictionary called user_profile with these exact fields and values: 'name': 'Alice', 'age': 30, 'is_active': true
Firebase
Need a hint?

Use Python dictionary syntax with exact keys and values.

2
Add a timestamp field for the current time
Import datetime from datetime module and create a variable called current_time set to datetime.datetime.now()
Firebase
Need a hint?

Use datetime.now() to get the current timestamp.

3
Add timestamp and array fields to the document data
Add a new key 'last_login' with value current_time and a key 'favorite_colors' with value ['red', 'green', 'blue'] to the user_profile dictionary
Firebase
Need a hint?

Add the new keys and values inside the user_profile dictionary.

4
Complete Firestore document creation code
Import firestore from firebase_admin, initialize the client as db = firestore.client(), and write the user_profile dictionary to the collection 'users' with document ID 'alice123' using db.collection('users').document('alice123').set(user_profile)
Firebase
Need a hint?

Use Firestore client to write the document with the exact collection and document ID.