【发布时间】:2020-06-18 07:21:39
【问题描述】:
我正在尝试使用这个工具来测试我的 NodeJS 应用程序:
https://cloud.google.com/sdk/gcloud/reference/beta/emulators/firestore
当我尝试向 firestore 数据库添加内容时,我收到此错误:
Error: Unable to detect a Project Id in the current environment.
我认为这很正常,因为本地没有GCP项目。
我想我必须配置firestore:
const Firestore = require('@google-cloud/firestore');
const db = new Firestore({
projectId: 'YOUR_PROJECT_ID',
keyFilename: '/path/to/keyfile.json',
});
使用 Google Cloud Firestore 模拟器时,如何创建“虚拟”项目 ID? 另外,密钥文件是强制性的吗?
如果存在“FIRESTORE_EMULATOR_HOST”环境变量,则最终目标是使用本地模拟器进行 firestore。
【问题讨论】:
标签: node.js google-cloud-platform google-cloud-firestore