问题
I have 50 realtime firebase database instances which are all identical.
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...
回答1:
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)
来源:https://stackoverflow.com/questions/53423799/how-to-trigger-firebase-function-on-all-database-instances-rather-than-default-o