问题描述
我有 50 个完全相同的实时 firebase 数据库实例.
I have 50 realtime firebase database instances which are all identical.
是否可以让我的所有 firebase 函数在所有实例上触发,而不仅仅是默认实例?
Is it possible to get all my firebase functions to trigger on all instances, rather than just the default instance?
我知道你可以做到这一点
I know you can do this
exports.myWriteFunction = functions.database.instance('my-secondary-db').ref('path/to/data').onUpdate((snap, context) => { ... })
但我真的很想在每个实例上运行这个函数...
But I really want to run this function on every instance...
推荐答案
无法自动将函数与所有数据库实例关联.您必须将它与您自己的代码中的每一个关联起来,尽管您当然可以简单地定义一个将所有这些关联起来的函数体:
There is no way to automatically associate a function with all database instances. You will have to associate it with each in your own code, although you can of course simply define a single function body that you associate all of them with:
const myfunc = (snap, context) => { ... }
exports.myWriteFunction1 = functions.database.instance('my-secondary-db').ref('path/to/data').onUpdate(myfunc)
exports.myWriteFunction2 = functions.database.instance('my-tertiary-db').ref('path/to/data').onUpdate(myfunc)
这篇关于如何在所有数据库实例上触发firebase函数而不是默认一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!