firebase realtime funtions using multiple databases

孤街醉人 提交于 2020-03-04 19:39:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!