现已推出具有 MongoDB 兼容性的 Firestore 企业版!
了解详情。
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Cloud Firestore
plat_ios
plat_android
plat_web
plat_flutter
plat_cpp
plat_unity
plat_node
plat_java
plat_python
plat_go
Sử dụng cơ sở dữ liệu đám mây NoSQL linh hoạt, có thể mở rộng của chúng tôi,
trên cơ sở hạ tầng Google Cloud, để lưu trữ và đồng bộ hoá dữ liệu cho ứng dụng khách và
phát triển phía máy chủ.
Cloud Firestore là một cơ sở dữ liệu linh hoạt và có thể mở rộng cho thiết bị di động, web,
và máy chủ từ Firebase và Google Cloud. Thích
Firebase Realtime Database thân mến! Dịch vụ này giúp dữ liệu của bạn luôn được đồng bộ hoá trên các ứng dụng thông qua
trình nghe theo thời gian thực cũng như hỗ trợ ngoại tuyến cho thiết bị di động và web để bạn có thể
tạo các ứng dụng thích ứng hoạt động bất kể độ trễ mạng hoặc Internet
khả năng kết nối. Cloud Firestore cũng cung cấp khả năng tích hợp liền mạch với Firebase khác
và Google Cloud sản phẩm, bao gồm Cloud Functions.
Bắt đầu
Các chức năng chính
Tính linh hoạt |
Mô hình dữ liệu Cloud Firestore hỗ trợ các cấu trúc dữ liệu phân cấp và linh hoạt.
Lưu trữ dữ liệu của bạn trong tài liệu và được sắp xếp thành bộ sưu tập. Tài liệu
có thể chứa các đối tượng lồng nhau phức tạp ngoài các bộ sưu tập con.
|
Truy vấn biểu hiện |
Trong Cloud Firestore, bạn có thể sử dụng các truy vấn để truy xuất từng
các tài liệu cụ thể hoặc để truy xuất tất cả tài liệu trong một tập hợp
khớp với tham số truy vấn của bạn. Truy vấn của bạn có thể bao gồm nhiều truy vấn theo chuỗi
cũng như kết hợp cả tính năng lọc và sắp xếp. URL cũng được lập chỉ mục theo mặc định,
vì vậy, hiệu suất truy vấn tỷ lệ thuận với quy mô của nhóm kết quả, chứ không phải
tập dữ liệu của bạn.
|
Cập nhật theo thời gian thực |
Giống như Realtime Database, Cloud Firestore sử dụng tính năng đồng bộ hoá dữ liệu để cập nhật dữ liệu trên
bất kỳ thiết bị được kết nối nào. Tuy nhiên, tính năng này cũng được thiết kế
để giúp bạn
tìm nạp truy vấn một cách hiệu quả.
|
Hỗ trợ ngoại tuyến |
Cloud Firestore lưu dữ liệu mà ứng dụng của bạn đang sử dụng vào bộ nhớ đệm để ứng dụng có thể ghi,
đọc, nghe và truy vấn dữ liệu ngay cả khi thiết bị không kết nối mạng. Khi
thiết bị có kết nối mạng trở lại, Cloud Firestore sẽ đồng bộ hoá mọi thay đổi cục bộ trở lại
thành Cloud Firestore.
|
Được thiết kế để mở rộng quy mô |
Cloud Firestore mang đến cho bạn những tính năng mạnh mẽ nhất của Google Cloud
cơ sở hạ tầng: tự động sao chép dữ liệu đa vùng, mạnh mẽ
đảm bảo tính nhất quán, hoạt động hàng loạt nguyên tử và giao dịch thực
của Google. Chúng tôi đã thiết kế Cloud Firestore để xử lý cơ sở dữ liệu khó nhất
tải công việc lớn nhất từ các ứng dụng lớn nhất thế giới.
|
Tính năng này hoạt động như thế nào?

Cloud Firestore là một cơ sở dữ liệu NoSQL, được lưu trữ trên đám mây mà Apple, Android và web của bạn
các ứng dụng có thể truy cập trực tiếp thông qua SDK gốc. Có Cloud Firestore
trong Node.js, Java, Python, Unity, C++ và Go SDK gốc, ngoài REST và
API RPC.
Theo mô hình dữ liệu NoSQL của Cloud Firestore, bạn lưu trữ dữ liệu trong các tài liệu
chứa các trường liên kết đến các giá trị. Các tài liệu này được lưu trữ trong
Bộ sưu tập, là vùng chứa cho tài liệu mà bạn có thể dùng để
sắp xếp dữ liệu và tạo truy vấn. Tài liệu hỗ trợ nhiều chế độ xem
các kiểu dữ liệu, từ các chuỗi và số đơn giản đến
các đối tượng phức tạp, lồng ghép vào nhau. Bạn cũng có thể tạo các tập hợp con trong
và xây dựng các cấu trúc dữ liệu phân cấp mà có thể mở rộng quy mô khi
phát triển. Mô hình dữ liệu Cloud Firestore hỗ trợ mọi
cấu trúc dữ liệu phù hợp nhất với ứng dụng của bạn.
Ngoài ra, hoạt động truy vấn trong Cloud Firestore rất ý nghĩa, hiệu quả và linh hoạt.
Tạo các truy vấn nông để truy xuất dữ liệu ở cấp tài liệu mà không cần phải
truy xuất toàn bộ bộ sưu tập hoặc bất kỳ tập hợp con nào được lồng. Thêm cách sắp xếp,
lọc và giới hạn đối với các truy vấn hoặc con trỏ của bạn ở
phân trang kết quả của bạn. Để cập nhật dữ liệu trong ứng dụng mà không cần truy xuất
toàn bộ cơ sở dữ liệu của bạn mỗi khi có một bản cập nhật, hãy thêm trình nghe theo thời gian thực.
Khi thêm trình nghe theo thời gian thực vào ứng dụng, bạn sẽ nhận được thông báo tổng quan nhanh về dữ liệu bất cứ khi nào
dữ liệu mà các ứng dụng khách của bạn đang theo dõi các thay đổi, chỉ truy xuất dữ liệu mới
thay đổi.
Bảo vệ quyền truy cập vào dữ liệu của bạn trong Cloud Firestore bằng Firebase Authentication và
Cloud Firestore Security Rules cho nền tảng Android, Apple và JavaScript hoặc Identity
và Quản lý quyền truy cập (IAM) cho ngôn ngữ phía máy chủ.
Lộ trình triển khai
|
Tích hợp các SDK Cloud Firestore |
Nhanh chóng đưa các ứng dụng vào thông qua Gradle, CocoaPods hoặc một tập lệnh bao gồm. |
|
Bảo mật dữ liệu của bạn |
Sử dụng Cloud Firestore Security Rules hoặc giải pháp Quản lý danh tính và quyền truy cập (IAM) để bảo mật
dữ liệu của bạn cho việc phát triển web/thiết bị di động và máy chủ. |
|
Thêm dữ liệu |
Tạo tài liệu và bộ sưu tập trong cơ sở dữ liệu của bạn. |
|
Nhận dữ liệu |
Tạo truy vấn hoặc sử dụng trình nghe theo thời gian thực để truy xuất dữ liệu từ
cơ sở dữ liệu. |
Các bước tiếp theo
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-17 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-17 UTC."],[],[],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)."]]