How to use Google Cloud Firestore
· Category: Cloud Computing
Short answer
Cloud Firestore is a serverless NoSQL document database with real-time sync, automatic scaling, and strong consistency.
Steps
- Create a Firestore database in Native mode.
- Structure data as collections of documents.
- Query with SDKs or the console:
db.collection('users').where('age', '>', 21).get()
- Enable offline persistence for mobile and web clients.
Tips
- Denormalize data for query performance; use subcollections for hierarchy.
- Security rules control access at the document level.
- Export data regularly for backup and compliance.
Common issues
- Complex filtering across fields requires composite indexes.
- Document size limit is 1 MB; store large blobs in Cloud Storage.