现已推出具有 MongoDB 兼容性的 Firestore 企业版!
了解详情。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Cloud Firestore
plat_ios
plat_android
plat_web
plat_flutter
plat_cpp
plat_unity
plat_node
plat_java
plat_python
plat_go
我們彈性且可擴充的 NoSQL 雲端資料庫建立於 Google Cloud 基礎架構上,可儲存及同步處理用戶端與伺服器端部署項目的資料。
Cloud Firestore 是 Firebase 和 Google Cloud 提供的資料庫,具備彈性與擴充性,適用於行動裝置、網頁和伺服器開發。與
Firebase Realtime Database 類似,Firestore 會透過即時事件監聽器,在用戶端應用程式間同步處理資料,並支援離線使用行動版和網頁版,因此只要應用程式能夠回應,就能建構相關工作,不受網路延遲或連線問題影響。Cloud Firestore 也可與其他 Firebase 和 Google Cloud 產品 (包括 Cloud Functions) 完美整合。
Cloud Firestore 提供兩種版本,可滿足不同需求。
瞭解各個版本
主要功能
彈性 |
Cloud Firestore 資料模型支援彈性的階層式資料結構。
將資料儲存至文件中,並將文件整理成集合。除了子集合外,文件也能含有複雜的巢狀物件。 |
生動查詢 |
在 Cloud Firestore 中,您可以使用查詢擷取符合查詢參數的特定個別文件,或某個集合中的所有文件。查詢可包含多個鏈式篩選條件,並搭配篩選與排序選項。 |
即時更新 |
和 Realtime Database 一樣,Cloud Firestore 是以資料同步處理的方式更新連線裝置的資料,不過在設計上也能高效率地完成簡單的一次性擷取查詢。 |
支援離線使用 |
Cloud Firestore 會快取應用程式常用的資料,因此即使裝置離線,應用程式也能寫入、讀取、監聽和查詢資料。裝置恢復連線時,Cloud Firestore 就會將在本機進行的任何變更同步回傳到 Cloud Firestore 上。 |
可輕鬆調度資源 |
Cloud Firestore 運用 Google Cloud 強大的基礎架構,提供自動多區域資料複寫、同步一致性保證、完整批次作業,並支援 ACID 交易。我們設計 Cloud Firestore 的目的,是為了處理全球最大應用程式中最艱鉅的資料庫工作負載。 |
與 MongoDB 相容 |
Cloud Firestore 提供與 MongoDB 相容的 API。您可以在Enterprise 版中使用現有的 MongoDB 應用程式程式碼、驅動程式、工具,以及與 MongoDB 整合的開放原始碼生態系統,搭配 Cloud Firestore。 |
運作原理

Cloud Firestore 是雲端代管的 NoSQL 資料庫,Apple、Android 和網路應用程式可透過原生 SDK 直接存取。Cloud Firestore 也提供原生 Node.js、Java、Python、Unity、C++ 和 Go SDK,以及 REST 和 RPC API。
按照「Cloud Firestore」的文件資料模型,儲存包含對應至值的欄位的資料。這些文件會儲存在集合中,集合是文件的容器,可用於整理資料及建構查詢。文件支援許多不同的資料類型,從簡單的字串和數字,到複雜的巢狀物件都適用。您也可以在文件中建立子集合,並建構階層式資料結構,隨著資料庫擴充而擴充。Cloud Firestore 資料模型支援最適合應用程式的資料結構。
此外,Cloud Firestore 中的查詢具有表現力、效率和彈性。建立淺層查詢,即可在文件層級擷取資料,不必擷取整個集合或任何巢狀子集合。在查詢或游標中新增排序、篩選和限制,即可將結果分頁。如要讓應用程式中的資料保持最新狀態,不必在每次更新時擷取整個資料庫,請新增即時監聽器。在應用程式中新增即時監聽器,即可在用戶端應用程式監聽的資料變更時收到資料快照通知,並只擷取新變更。
使用 Firebase Authentication 和 Cloud Firestore Security Rules (適用於 Android、Apple 平台和 JavaScript),或 Identity and Access Management (IAM) (適用於伺服器端語言),保護 Cloud Firestore 中的資料存取權。
實作路徑
|
整合 Cloud Firestore SDK |
透過 Gradle、CocoaPods 或指令碼,快速納入用戶端。 |
|
確保資料安全 |
請分別使用 Cloud Firestore Security Rules 或 Identity and Access Management (IAM),保護行動/網路和伺服器開發的資料。 |
|
新增資料 |
在資料庫中建立文件和集合。 |
|
取得資料 |
建立查詢或使用即時監聽器,從資料庫擷取資料。 |
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["Cloud Firestore \nplat_ios plat_android plat_web plat_flutter plat_cpp plat_unity plat_node plat_java plat_python plat_go \nUse our flexible, scalable NoSQL cloud database, built\non Google Cloud infrastructure, to store and sync data for client- and\nserver-side development. \n\nCloud Firestore is a flexible, scalable database for mobile, web,\nand server development from Firebase and Google Cloud. Like\nFirebase Realtime Database, it keeps your data in sync across client apps through\nrealtime listeners and offers offline support for mobile and web so you can\nbuild responsive apps that work regardless of network latency or Internet\nconnectivity. Cloud Firestore also offers seamless integration with other Firebase\nand Google Cloud products, including Cloud Functions.\n\nCloud Firestore is available in two editions to meet different needs.\n[Learn about the editions](/docs/firestore/editions)\n\nKey capabilities\n\n|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Flexibility | The Cloud Firestore data model supports flexible, hierarchical data structures. Store your data in documents, organized into collections. Documents can contain complex nested objects in addition to subcollections. |\n| Expressive querying | In Cloud Firestore, you can use queries to retrieve individual, specific documents or to retrieve all the documents in a collection that match your query parameters. Your queries can include multiple, chained filters and combine filtering and sorting. |\n| Realtime updates | Like Realtime Database, Cloud Firestore uses data synchronization to update data on any connected device. However, it's also designed to make simple, one-time fetch queries efficiently. |\n| Offline support | Cloud Firestore caches data that your app is actively using, so the app can write, read, listen to, and query data even if the device is offline. When the device comes back online, Cloud Firestore synchronizes any local changes back to Cloud Firestore. |\n| Designed to scale | Cloud Firestore brings you the best of Google Cloud's powerful infrastructure: automatic multi-region data replication, strong consistency guarantees, atomic batch operations, and ACID transaction support. We've designed Cloud Firestore to handle the toughest database workloads from the world's biggest apps. |\n| MongoDB compatibility | Cloud Firestore offers a MongoDB-compatible API. You can use existing MongoDB application code, drivers, tools, and the open-source ecosystem of MongoDB integrations with Cloud Firestore in the [Enterprise edition.](/docs/firestore/enterprise/mongodb-compatibility-overview) |\n\nHow does it work?\n\nCloud Firestore is a cloud-hosted, NoSQL database that your Apple, Android, and\nweb\napps can access directly via native SDKs. Cloud Firestore is also available\nin native Node.js, Java, Python, Unity, C++ and Go SDKs, in addition to REST and\nRPC APIs.\n\nFollowing Cloud Firestore's document data model, you store data that\ncontain fields mapping to values. These documents are stored in\ncollections, which are containers for your documents that you can use to\norganize your data and build queries. Documents support many different\n[data types](/docs/firestore/manage-data/data-types), from simple strings and numbers, to\ncomplex, nested objects. You can also create subcollections within\ndocuments and build hierarchical data structures that scale as your\ndatabase grows. The Cloud Firestore [data model](/docs/firestore/data-model) supports whatever\ndata structure works best for your app.\n\nAdditionally, querying in Cloud Firestore is expressive, efficient, and flexible.\nCreate shallow queries to retrieve data at the document level without needing to\nretrieve the entire collection, or any nested subcollections. Add sorting,\nfiltering, and limits to your queries or cursors to\npaginate your results. To keep data in your apps current, without retrieving\nyour entire database each time an update happens, add realtime listeners.\nAdding realtime listeners to your app notifies you with a data snapshot whenever\nthe data your client apps are listening to changes, retrieving only the new\nchanges.\n\nProtect access to your data in Cloud Firestore with Firebase Authentication and\nCloud Firestore Security Rules for Android, Apple platforms, and JavaScript, or Identity\nand Access Management (IAM) for server-side languages.\n\nImplementation path\n\n|---|------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| | Integrate the Cloud Firestore SDKs | Quickly include clients via Gradle, CocoaPods, or a script include. |\n| | Secure your data | Use Cloud Firestore Security Rules or Identity and Access Management (IAM) to secure your data for mobile/web and server development, respectively. |\n| | Add Data | Create documents and collections in your database. |\n| | Get Data | Create queries or use realtime listeners to retrieve data from the database. |\n\nNext steps\n\n- [Get started](/docs/firestore/quickstart) with Cloud Firestore --- set up your database, then add data and start reading it.\n- Learn more about the Cloud Firestore [data model](/docs/firestore/data-model).\n- Explore the [differences between Realtime Database and Cloud Firestore](/docs/firestore/rtdb-vs-firestore)."]]