现已推出具有 MongoDB 兼容性的 Firestore 企业版!
了解详情。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Cloud Firestore
plat_ios
plat_android
plat_web
plat_flutter
plat_cpp
plat_unity
plat_node
plat_java
plat_python
plat_go
这是一种基于Google Cloud 基础设施构建的灵活且可扩容的 NoSQL 云端数据库,可以使用它来存储和同步用于客户端及服务器端开发的数据。
Cloud Firestore 是一种灵活且可扩容的数据库,适用于在 Firebase 和 Google Cloud 上进行移动、Web 和服务器开发。与 Firebase Realtime Database 一样,它可以通过实时监听器使您的数据在各个客户端应用之间保持同步,并为移动和 Web 应用提供离线支持,帮助您构建无论网络延迟时间或互联网连接状况如何都能快速响应的应用。Cloud Firestore 还提供与其他 Firebase 和 Google Cloud 产品(包括 Cloud Functions)的无缝集成。
开始
主要功能
灵活性 |
Cloud Firestore 数据模型支持灵活的分层数据结构。将您的数据存储在文档中,并整理成集合。文档中不仅可以包含子集合,还可以包含复杂的嵌套对象。 |
表达能力出色的查询 |
在 Cloud Firestore 中,您可以使用查询来检索特定的个别文档,或者检索某个集合中与查询参数匹配的所有文档。您的查询可以包含多个链式过滤条件,还可以将过滤和排序功能结合使用。默认情况下系统会为查询编制索引,所以查询性能与结果集的大小(而不是数据集的大小)成比例。 |
实时更新 |
与 Realtime Database 一样,Cloud Firestore 也使用数据同步功能来更新所有已连接设备上的数据。但是,它也可以高效地进行简单的一次性提取式查询。 |
离线支持 |
Cloud Firestore 会缓存您的应用正在使用的数据,因此,即使在设备处于离线状态时,该应用也可以写入、读取、监听和查询数据。当设备恢复在线状态时,Cloud Firestore 会将所有本地更改同步回 Cloud Firestore。 |
可扩容设计 |
Cloud Firestore 可让您充分利用 Google Cloud 强大的基础设施:自动多区域数据复制、强大的一致性保证、原子批量操作以及真正的事务支持。我们设计 Cloud Firestore 的宗旨就是为了应对大型应用中棘手的数据库工作负载。 |
工作原理

Cloud Firestore 是一种托管在云端的 NoSQL 数据库,Apple、Android 和 Web 应用可以直接通过原生 SDK 访问它。除了 REST API 和 RPC API 之外,在原生 Node.js、Java、Python、Unity、C++ 和 Go SDK 中也可以使用 Cloud Firestore。
按照 Cloud Firestore 的 NoSQL 数据模型,您要将数据存储在包含映射到值的字段的文档中。这些文档存储在集合中,而集合是文档中的容器,可用于整理数据和构建查询。文档支持许多不同的数据类型,包括简单的字符串和数值以及复杂的嵌套对象。您还可以在文档中创建子集合,并构建能够随数据库增长而扩容的分层数据结构。Cloud Firestore 数据模型可支持最适合您的应用的任何数据结构。
另外,Cloud Firestore 中的查询高效、灵活并且表达能力出色。创建浅查询可以在文档级别检索数据,而无需检索整个集合或任何嵌套的子集合。您可以为查询添加排序、过滤和数量限制功能,或添加游标以对结果进行分页。要想使您应用中的数据保持最新,但又不想在每次更新时都检索整个数据库,可添加实时监听器。将实时监听器添加到您的应用后,每当客户端应用监听的数据发生更改时,系统就会通过一个数据快照通知您,并且只检索新的更改。
借助适用于 Android、Apple 平台和 JavaScript 的 Firebase Authentication 和 Cloud Firestore Security Rules,或适用于服务器端编程语言的 Identity and Access Management (IAM),为 Cloud Firestore 中的数据访问提供保护。
实现流程
|
集成 Cloud Firestore SDK |
通过 Gradle、CocoaPods 或脚本添加方式快速添加客户端。 |
|
保护您的数据 |
对于移动/Web 开发和服务器开发,分别使用 Cloud Firestore Security Rules 或 Identity and Access Management (IAM) 来保护您的数据。 |
|
添加数据 |
在您的数据库中创建文档和集合。 |
|
获取数据 |
创建查询或使用实时监听器从数据库中检索数据。 |
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-17。
[null,null,["最后更新时间 (UTC):2025-08-17。"],[],[],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\n[Get started](/docs/firestore/quickstart)\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. They're also indexed by default, so query performance is proportional to the size of your result set, not your data set. |\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 real transaction support. We've designed Cloud Firestore to handle the toughest database workloads from the world's biggest apps. |\n\nHow does it work?\n\nCloud Firestore is a cloud-hosted, NoSQL database that your Apple, Android, and web\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 NoSQL data model, you store data in documents 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)."]]