如何在同一项目中使用 Cloud Firestore 和实时数据库

How to use Cloud Firestore and Realtime Database in same project

Firebase 的文档有 following paragraph:

Using Cloud Firestore and Realtime Database: You can use both databases within the same Firebase app or project. Both NoSQL databases can store the same types of data and the client libraries work in a similar manner. Keep in mind the differences outlined above if you decide to use both databases in your app.

不过,我找不到任何有关如何将 Cloud Firestore 添加到具有实时数据库的现有项目的文档。我最终会升级到 Cloud Firestore,但在我转换生产数据库之前想要一些时间来试验和学习。

有人知道如何在同一个 Firebase 项目中使用这两个数据库吗?

当您在控制台中转到您的项目并选择数据库产品时,您应该第一次看到类似这样的内容:

这是一个 selector,可让您选择在项目中查看实时数据库或 Firestore。您可以使用 selector.

在两者之间切换

第一次 select Cloud Firestore 时,它​​会要求您进行配置。从 "test mode" 开始,设置无需身份验证的完全读写,以便快速入门,但当然,您应该始终在生产中设置规则。

设置 Firestore 后,您应该能够使用两个客户端 SDK 独立访问两个数据库。