建立 Firestore 資料庫時,您可以選擇與 Datastore API 相容。這是資料庫層級的設定,可提供回溯相容性,並停用對新 Firestore 功能的存取權。您不必為專案中的所有資料庫啟用 Datastore 模式的 Firestore (Datastore) 相容性。
建議您僅針對依附於 Datastore API 的應用程式使用 Datastore 相容性,例如舊版 App Engine 應用程式。Datastore 相容性是 Firestore 之上的 API 層,具有相同的可用性、效能、一致性和擴充性。除了能與 App Engine 整合外,Datastore 相容性與直接使用 Firestore 相比,沒有任何優勢。
Firestore
Firestore 是企業級 NoSQL 文件資料庫,與 MongoDB 相容,專為自動調整資源配置、提供高效能,以及協助輕鬆開發應用程式而打造。Firestore 是 Datastore 的後繼產品。您可以使用 Firestore 處理數百萬項作業的伺服器端後端架構,以及行動和網頁應用程式。
除了舊版 Datastore 的功能外,Firestore 還提供下列功能:
- 具同步一致性的儲存空間層
- 集合與文件資料模型
- 即時更新
- 行動和網路用戶端程式庫
Firestore 能回溯相容 Datastore,但資料模型、即時更新內容以及行動和網路用戶端程式庫等新功能則無法回溯相容。如要存取所有 Firestore 功能,請勿將資料庫設定為與 Datastore 相容。
Datastore 相容性限制
除非您是使用以 Datastore 建構的舊版 App Engine 應用程式,否則建議不要使用 Datastore 相容性,因為這樣會無法存取許多實用的 Firestore 功能,例如:
- 豐富的查詢功能:資料庫會接受 Datastore API 要求,並拒絕提供豐富查詢功能的 Firestore API 要求。
- 更多索引類型:資料庫會使用 Datastore 索引,而非 Firestore 索引,因此提供更多索引類型,且可設定程度更高。
- 即時功能:無法使用 Firestore 即時功能。
後續步驟
如要開始使用 Firestore 用戶端程式庫,請參閱「建立 Firestore 資料庫並連結伺服器用戶端程式庫」。
如要開始使用與 Datastore 相容的 Firestore,請參閱「開始使用 Datastore 用戶端程式庫」。