I want to listen to two databases in my google cloud functions so I tried this
const app1 = admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://honey.firebaseio.com"
});
const app2 = admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://honey-d8.firebaseio.com/"
}, 'app2');
// Get the default database instance for an app1
var OperationDB = admin.database().ref();
// Get a database instance for app2
var userDB = admin.database(app2).ref();
then I tried to call the second database
exports.onBoardNewUser = functions.userDB.ref('/Users/').onCreate((snapshot, context) => {
})
whenever I attempt to deploy the file it gives this error
Cannot read property 'ref' of undefined
The two databases are in the same project
I have tried different variations but no luck. what am I doing wrong an how can I fix this ?