问题
We have two different firebase projects each with its own firebase functions and realtime database used.
we have come to a situation where we want to leverage one of the dataset (a node in the realtime db) from project 1 into the project 2.
As this node is read-only true so i can a access it in the format
https://myproject.firebaseio.com/prj1db/nodeX.json
but that will give entire data for this node. What i need is to query specific data like i do using below format for the db attached to the same project in the firebase function:
const rsp = await db.ref("/users/").orderByChild("color").equalTo("pink).once("value")
is there a way?
回答1:
So above answer did not work even being super close to what i need. The above response ends up giving error indicating there is a security issue.
What worked for me was that i used the service key approach with below code
const scanbuddyDBApp = admin.initializeApp({
credential: admin.credential.cert("./src/scanbuddy_service_key.json"),
databaseURL: "https://mydb.firebaseio.com",
}, 'scanbuddy');
来源:https://stackoverflow.com/questions/60035250/firebase-realtime-funtions-using-multiple-databases