0
0
Firebasecloud~10 mins

Supported data types in Firebase - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Supported data types
Start: Define Data
Check Data Type
String
Store in DB
Retrieve & Use
End
Data is defined, its type is checked among supported types, then stored and retrieved from Firebase.
Execution Sample
Firebase
docRef.set({
  name: "Alice",
  age: 30,
  isMember: true
});
Stores a document with string, number, and boolean data types in Firebase.
Process Table
StepData FieldValueDetected TypeAction
1name"Alice"StringStore as string
2age30NumberStore as number
3isMembertrueBooleanStore as boolean
4All fieldsN/AN/ADocument stored successfully
5RetrieveN/AN/AData retrieved with original types
💡 All supported data types stored and retrieved correctly.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
nameundefined"Alice""Alice""Alice""Alice"
ageundefinedundefined303030
isMemberundefinedundefinedundefinedtruetrue
Key Moments - 2 Insights
Why does Firebase store numbers without quotes but strings with quotes?
Because Firebase detects the data type by the value format: quotes mean string, no quotes with digits mean number, as shown in execution_table steps 1 and 2.
Can I store a boolean value as a string to represent true/false?
You can, but Firebase treats it as a string, not a boolean. See execution_table step 3 where true is stored as a boolean, not a string.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what type is the 'age' field detected as at step 2?
AString
BNumber
CBoolean
DUndefined
💡 Hint
Check the 'Detected Type' column for step 2 in the execution_table.
At which step is the boolean value stored in Firebase?
AStep 3
BStep 2
CStep 1
DStep 4
💡 Hint
Look for the 'isMember' field in the execution_table.
If you changed the 'age' value to "30" (with quotes), how would the detected type change?
AIt would remain Number
BIt would become Boolean
CIt would become String
DIt would be Undefined
💡 Hint
Refer to how quotes affect type detection in execution_table steps 1 and 2.
Concept Snapshot
Firebase supports these data types:
- String: text in quotes
- Number: digits without quotes
- Boolean: true or false
Store data by type; Firebase keeps types on retrieval.
Use correct types to avoid errors.
Full Transcript
In Firebase, data is stored with clear types: strings, numbers, and booleans. When you save a document, Firebase checks each field's value to detect its type. For example, text inside quotes is a string, digits without quotes are numbers, and true/false are booleans. This ensures data is stored correctly and can be retrieved with the same type. The example shows storing a name as a string, age as a number, and membership status as a boolean. Understanding these types helps avoid confusion and errors when working with Firebase data.