Thuta Learning
Firebase Tutorial
IntermediateDevOps & Toolsအလယ်အလတ်

Data ပုံစံ (Structure)

Firebase Tutorialသင်ခန်းစာ 12

Data ပုံစံ (Structure)

Firestore structure ကိုအစကတည်းက စနစ်ကျကျစဉ်းစားထားရင် နောက်ပိုင်း query, rules, performance တွေ အများကြီးကောင်းလာပါတယ်။

Simple Notes App Structure

javascript
users/{userId}
  name: 'Sai'
  email: 'sai@example.com'

notes/{noteId}
  ownerId: '{userId}'
  title: 'Firebase လေ့လာရန်'
  content: 'Auth, Firestore, Storage စမ်းမယ်'
  createdAt: serverTimestamp()
  isPinned: false

ဘာကြောင့် ownerId ထည့်တာလဲ?

ownerId က note ကိုဘယ် user ပိုင်သလဲဆိုတာသိအောင်လုပ်ပေးပါတယ်။ Query တွင်လည်း where('ownerId', '==', user.uid) နဲ့ ကိုယ့် note တွေကိုပဲဖတ်နိုင်ပြီး Security Rules ထဲမှာလည်း owner ကိုစစ်နိုင်ပါတယ်။

Best practice

Document field name တွေကို short ဖြစ်အောင်လုပ်လို့ရပေမဲ့ အဓိပ္ပါယ်ရှင်းနေဖို့ပိုအရေးကြီးပါတယ်။ ttl ထက် title, ct ထက် createdAt က နောက်လူဖတ်ရတာ ပိုကောင်းပါတယ်။

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Data ပုံစံ (Structure) | Thuta Learning