如何在远程数据库上使用函数、触发器运行firebase模拟器进行本地开发?

如何在远程数据库上使用函数、触发器运行firebase模拟器进行本地开发?,firebase,google-cloud-firestore,localhost,google-cloud-functions,firebase-cli,Firebase,Google Cloud Firestore,Localhost,Google Cloud Functions,Firebase Cli,我正在构建一个带有云函数的firebase API,并希望访问我的生产数据库进行本地测试。 我的问题是: 当我启动两个firebase emulator函数和firestore时 firebase emulators:start 1-我的自定义API终结点运行在这台机器上 2-我的触发器到达上的本地数据库,而我没有设置FIRESTORE\u EMULATOR\u HOST=localhost:8080我想访问我的生产数据库 或 当我仅使用emulator启动我的函数时 firebase em

我正在构建一个带有云函数的firebase API,并希望访问我的生产数据库进行本地测试。 我的问题是:

当我启动两个firebase emulator函数和firestore时

firebase emulators:start 
1-我的自定义API终结点运行在这台机器上

2-我的触发器到达上的本地数据库,而我没有设置FIRESTORE\u EMULATOR\u HOST=localhost:8080我想访问我的生产数据库

或 当我仅使用emulator启动我的函数时

firebase emulators:start --only function
…但我的触发器未到达,可能是因为此警告

i  functions[userOnCreate]: function ignored because the firestore emulator does not exist or is not running.
另一方面,我正在构建一个reactjs应用程序,它也在本地主机上运行firebase:3000

我使用firebase SDK从此应用程序调用我的本地API。要访问emulator,我添加以下行:

firebase.functions.useFunctionsEmulator('http://localhost:5001');

本地模拟器不适用于实际的云托管数据库实例。一切都必须是本地的


您随时可以。

您必须为firebase模拟器使用firebase服务:开始

在开始时,我只使用firebase init函数初始化了一个函数项目,而不使用firestore emulator。。。我几乎可以肯定我已经用这种方法测试了我的未部署触发器。这是可能的,或者我在做梦?您可以在本地测试访问任何数据库的HTTP触发器,但不能在本地测试为响应远程数据库上的更改而触发的数据库触发器。您必须使用函数shell来模拟启动函数的数据库更改。哦,是的,对不起。它使用了firebase函数:shell我现在记得。。。