Cloud Pokročilý
Google Firestore — Serverless NoSQL¶
GCPFirestoreNoSQLReal-time 5 min čtení
Firestore datový model, real-time listeners, security rules a offline podpora.
Datový model¶
// collections → documents → subcollections
await setDoc(doc(db, 'users', 'uid123'), {
name: 'Jan Novák', email: 'jan@example.com',
createdAt: serverTimestamp()
});
Real-time Listeners¶
onSnapshot(query(collection(db, 'messages'),
where('roomId', '==', 'room-42'),
orderBy('createdAt', 'desc'), limit(50)
), snapshot => {
snapshot.docChanges().forEach(change => {
if (change.type === 'added') renderMessage(change.doc.data());
});
});
Security Rules¶
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if request.auth != null;
allow write: if request.auth.uid == userId;
}
}
}
Shrnutí¶
Firestore = ideální pro mobile/web apps s real-time sync a offline podporou.
Potřebujete pomoct s implementací?¶
Náš tým má zkušenosti s návrhem a implementací moderních architektur. Rádi vám pomůžeme.