【发布时间】:2021-04-09 10:30:26
【问题描述】:
可以在我的笔记本电脑上使用firebase-functions 吗?如果没有,firebase-admin 是唯一剩下的选择吗?
这里有一些例子:
- How can I rent and use my own servers for cloud functions?
- Listen only to additions to a cloud firestore collection?
- Does Firebase Admin SDK perform any caching?
我可以在我的笔记本电脑上创建一个index.js 文件,npm install firebase-admin 模块,链接到我的 Firestore 数据库并对数据进行很好的更改,使用 admin-credentials。当我也尝试 npm install firebase-functions 使用事件触发器 onCreate/onWrite/onUpdate/onDelete 时,他们没有得到任何更新?
据我了解,使用事件触发器的唯一方法是上传到云函数,因为您需要 Google 的基础架构才能使用这些函数,而您不能在本地机器上使用它们,您可以使用 @ 987654331@包。您可以使用本地模拟器(?),但它还没有准备好生产并且不适合该用例(?)。
因此,为了在我的 Firestore 数据库中侦听新事件,仅使用我的笔记本电脑(不是 Google Cloud Functions 平台或其他一些服务器托管选项),我必须使用来自 firebase-admin npm 的 .onSnapshot()。
但是该模块无法缓存,您只能查询整个 firestore 数据库,下载每个文档。
这是正确的吗?或者有什么办法可以让firebase-functions 使用firebase-admin + 管理员凭据从我的笔记本电脑服务器上工作,就像我将文件上传到云平台一样。我不需要这部分数据在云端,所以我想从笔记本电脑的终端进行更改和调整 firestore 数据库。
【问题讨论】:
标签: firebase google-cloud-platform google-cloud-firestore google-cloud-functions