场景 我使用命令行工具在 firebase 中创建了两个项目。第一个站点(比如 A)是一个使用托管、firestore、云功能和身份验证的 Web 应用程序。第二个站点(比如 B)是一种管理门户,它应该能够显示站点 A 中的所有数据。站点 B 使用与站点 A 不同的身份验证。
注意将来将会创建更多类似站点 A 的站点,而站点 B 仍将是所有站点的管理门户。
问题如何将 Firebase 中一个项目的数据转移到其他项目?
PS 我知道 SO 不允许这样做,但如果有更好的方法来做到这一点,我会很高兴知道。
最佳答案
您必须多次初始化 Firebase,每个项目一次。根据documentation :
// Initialize the default app
firebase.initializeApp(defaultAppConfig);
// Initialize another app with a different config
var otherApp = firebase.initializeApp(otherAppConfig, "other");
console.log(firebase.app().name); // "[DEFAULT]"
console.log(otherApp.name); // "other"
// Use the shorthand notation to retrieve the default app's services
var defaultStorage = firebase.storage();
var defaultDatabase = firebase.database();
// Use the otherApp variable to retrieve the other app's services
var otherStorage = otherApp.storage();
var otherDatabase = otherApp.database();
关于javascript - 如何从不同的 Firebase 项目获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51117459/