Firestore Schema¶
Cập nhật gần nhất: 17/03/2026
Trang này tóm tắt mô hình Firestore đang dùng cho app mobile và Cloud Functions.
Collection cốt lõi¶
clans: hồ sơ dòng họ và metadata tổng hợpbranches: cấu trúc chi và tham chiếu lãnh đạo chimembers: hồ sơ thành viên, vai trò, mảng quan hệ phi chuẩn hóarelationships: cạnh quan hệ chuẩninvites: bản ghi mời theo phone và child-accessusers: ngữ cảnh phiên cho auth/rules fallbacknotifications: hộp thư thông báo theo thành viênevents,funds,transactions,scholarshipPrograms,awardLevels,achievementSubmissions,auditLogs
Collection billing:
subscriptionssubscriptionInvoicespaymentTransactionspaymentWebhookEventsbillingSettingsbillingAuditLogs
Mẫu member + relationship¶
- nguồn chuẩn: cạnh trong
relationships - tối ưu đọc:
members.parentIds,members.childrenIds,members.spouseIds - callable quan hệ cập nhật mảng phi chuẩn hóa theo giao dịch
Session và token thiết bị¶
users/{uid}lưu ngữ cảnh truy cập:memberId,clanId,clanIds,branchId,primaryRole,accessModeusers/{uid}/deviceTokens/{token}lưu metadata route push
Truy vấn và index¶
Index chính nằm tại firebase/firestore.indexes.json:
- members theo clan + name
- members theo clan + branch + name
- members theo clan + generation
- relationships theo clan + person + type
- events theo clan/branch + start time
- notifications theo member + created time/read state
- billing theo clan + trạng thái thuê bao/hạn dùng + thứ tự thời gian giao dịch