Google Cloud

Firestore Complete Guide: Native vs Datastore Mode, Real-Time Sync, and Firebase Integration

2026-05-24
NicheeLab Editorial Team

Firestore is GCP's document-oriented NoSQL database, widely adopted as the backend for Mobile and Web applications. Its hallmarks are tight Firebase integration, real-time sync, offline support, and declarative access control via Security Rules.

The Two Modes

AspectNative modeDatastore mode
Released2017Datastore-compatible
Real-time syncYes
Mobile/Web SDKYes
Security RulesYes
Strong ConsistencyYesPartial (within ancestor queries)
Recommended for new projectsYes

Data Model

  • Collection: a set of documents (e.g. users)
  • Document: a JSON-like object up to 1 MB in size
  • Subcollection: a Collection nested under a Document
  • Field: a property inside a document (String / Number / Array / Map / Reference / GeoPoint, etc.)

Query Capabilities

  • Equality: where('status', '==', 'active')
  • Range: where('age', '>=', 20) (one field only)
  • Array contains: where('tags', 'array-contains', 'js')
  • OR: where(Filter.or(a, b)) (since 2023)
  • Composite Index: required for multi-field combinations (must be created in advance)
  • Collection Group: queries that span subcollections
  • Aggregation: count / sum / avg (since 2023)
  • Vector Search: KNN queries (preview from 2024)

Pricing

ItemPrice
Document reads$0.06 / 100,000
Document writes$0.18 / 100,000
Document deletes$0.02 / 100,000
Storage$0.18 / GB / month
NetworkStandard egress pricing
Monthly free tier50K reads / 20K writes / 20K deletes / 1 GB

Security Rules Example

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;
    }
    match /posts/{postId} {
      allow read: if true;
      allow create: if request.auth != null;
      allow update, delete: if request.auth.uid == resource.data.authorId;
    }
  }
}

Real-Time Sync

// JavaScript SDK
import { onSnapshot, doc } from "firebase/firestore";

const unsub = onSnapshot(doc(db, "chats", "room1"), (docSnap) => {
  console.log("Changes:", docSnap.data());
});
// Cleanup
unsub();

Comparison With Other NoSQL Stores

AspectFirestoreDynamoDBCosmos DBMongoDB Atlas
ModelDocumentKV + DocumentMulti-modelDocument
Real-time syncNativeDynamoDB StreamsChange feedChange Streams
Billing unitOperation countRCU/WCURUVM hours
Free tierYes (always-free)Yes (25 GB)Yes (1000 RU)$0/month Free Tier
Primary useMobile/WebServerless APIsMulti-cloudOSS-compatible

Typical Use Cases

  • Mobile/Web app backends (Firebase-integrated)
  • Chat and collaboration tools (real-time sync)
  • User profile management
  • E-commerce carts and orders (flexible structure via Subcollections)
  • IoT device state management
  • Product recommendations powered by Vector Search (since 2024)

Best Practices

  • Cache hot reads on the client side
  • Define Composite Indexes up front (detect them before deploy)
  • Keep each document under the 1 MB limit
  • Export large datasets to BigQuery for analytics
  • Unit-test your Security Rules with @firebase/rules-unit-testing
  • Use Firestore Bundles to accelerate initial data delivery

How are Firestore and Datastore related?

Firestore is the evolution of Datastore. Firestore in Native mode is the true next-generation product, while Firestore in Datastore mode is Datastore-compatible. For new projects, Native mode is the only sensible choice.

Is Firestore only for Firebase?

No. Firestore can be used from a plain GCP project as well. Firebase is a BaaS bundle that integrates Firestore, Auth, Storage, and more, which makes it the easier path for Web/Mobile apps.

How does real-time sync work?

The Firestore SDK's onSnapshot listener streams document changes to clients in real time over WebSocket. It is the more capable successor to Firebase Realtime Database.

What are the query limitations?

A single query can only use a range comparison on one field, and many queries require a Composite Index. Inequality filters are limited to a single field as well.

How is Firestore priced?

You pay for document reads, writes, and deletes, plus storage and network egress. The free tier covers 50,000 reads / 20,000 writes / 20,000 deletes / 1 GB of storage per month.

When should I use Firestore vs Cloud Spanner?

Firestore is a document NoSQL store, ideal for real-time Mobile/Web apps. Spanner is a NewSQL relational database for enterprise workloads with complex transactions. They solve entirely different problems.

How are Security Rules written?

Firestore Security Rules let you declaratively define read/write conditions. They integrate with Firebase Auth, making per-user access control straightforward.

Does Firestore support Vector Search?

Yes, in preview since 2024. It is built on ScaNN and supports KNN queries, so it can power RAG and recommendation workloads.

Related Articles: NoSQL / Mobile

GCP vs AWS ストレージ・DB 徹底比較|GCS/S3・BigQuery/Redshift・Spanner/DynamoDB (2026)

GCP と AWS のストレージ・データベースを徹底比較。Cloud Storage vs S3、BigQuery vs Redshift、Spanner vs DynamoDB / Aurora DSQL、Cloud SQL vs RDS、AlloyDB vs Aurora、Firestore vs DynamoDB、Bigtable vs DynamoDB を 2026 年最新版で網羅。

Spanner vs DynamoDB vs Cosmos DB 徹底比較|グローバル NoSQL / NewSQL 選び方 (2026)

Google Spanner / AWS DynamoDB / Azure Cosmos DB / Aurora DSQL の徹底比較。アーキ、料金、整合性 (Strong / Eventual)、Multi-region 書き込み、サーバレス対応、用途別おすすめを 2026 年最新版で網羅。

GCP Professional Cloud Database Engineer (PCDBE) 完全ガイド|Spanner・AlloyDB・Cloud SQL

Google Cloud Professional Cloud Database Engineer の試験範囲、Spanner / AlloyDB / Cloud SQL / Bigtable / Firestore、AWS DBS・Azure DP-300 比較を詳解。

Spanner 完全ガイド|グローバル分散 NewSQL の全機能・料金・他 DB 比較

Google Cloud Spanner の全機能解説。TrueTime、External Consistency、水平スケール、料金 (Processing Unit)、Spanner Graph、PostgreSQL Interface、AWS Aurora DSQL / CockroachDB 比較を網羅。

* Google Cloud and Firebase are trademarks of Google LLC. For the latest information, see the official Firestore docs.

Check what you learned with practice questions

Practice with certification-focused question sets

View GCP exam prep
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Google Cloud

Google Cloud Certification Roadmap (2026)

Choose your GCP certification path — Foundational, Associate...

Google Cloud

CDL Cloud Digital Leader: Complete Exam Guide (2026)

Pass the Cloud Digital Leader exam — cloud business value, G...

Google Cloud

GAIL Generative AI Leader: Complete Exam Guide (2026)

Pass the Generative AI Leader exam — Gemini, Vertex AI, Work...

Google Cloud

Vertex AI Fundamentals for GCP Certs (2026)

Vertex AI basics every cert candidate needs — Workbench, Pip...

Google Cloud

Associate Cloud Engineer (ACE): Complete Guide (2026)

Pass the Associate Cloud Engineer exam — Console, gcloud, pr...

Browse all Google Cloud articles (103)
© 2026 NicheeLab All rights reserved.