[英]What is the difference between Function.database and Firebase.database? When to use one over the other?
I am starting off with firebase and I have been reading significant amount of sample codes.我从 firebase 开始,并且一直在阅读大量示例代码。 One thing I notice is that some sample uses functions.database and some uses firebase.database when getting reference data.
我注意到的一件事是,一些示例在获取参考数据时使用 functions.database,而一些示例使用 firebase.database。
This for example uses functions.database https://firebase.google.com/docs/functions/database-events这例如使用 functions.database https://firebase.google.com/docs/functions/database-events
This one uses firebase.database https://firebase.google.com/docs/database/web/read-and-write这个使用 firebase.database https://firebase.google.com/docs/database/web/read-and-write
Is there any functional advantage using one over the other?使用一个比另一个有什么功能优势吗?
Thanks谢谢
They are used in two different contexts:它们用于两种不同的情况:
functions.database
is used when you register/create a Cloud Function that triggers on events from a specific Firebase Realtime Database instance. functions.database
在您注册/创建触发来自特定 Firebase 实时数据库实例的事件的Cloud Function时使用。 So it is used in code that is executed in the back-end , on the Cloud Function platform.firebase.database()
is used in the front-end , with the Client JavaScript SDK.firebase.database()
,配合 Client JavaScript SDK。 It is used to get an instance of firebase.database.Reference
, in order to read/write data from/to the Firebase Realtime Database.firebase.database.Reference
的实例,以便从/向 Firebase 实时数据库读取/写入数据。 So it all depends on where you plan to execute your code.所以这完全取决于您计划在哪里执行代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.