![](/img/trans.png)
[英]when i use firebase.database().goOnline(); I get an error
[英]What is the difference between Function.database and Firebase.database? When to use one over the other?
我從 firebase 開始,並且一直在閱讀大量示例代碼。 我注意到的一件事是,一些示例在獲取參考數據時使用 functions.database,而一些示例使用 firebase.database。
這例如使用 functions.database https://firebase.google.com/docs/functions/database-events
這個使用 firebase.database https://firebase.google.com/docs/database/web/read-and-write
使用一個比另一個有什么功能優勢嗎?
謝謝
它們用於兩種不同的情況:
functions.database
在您注冊/創建觸發來自特定 Firebase 實時數據庫實例的事件的Cloud Function時使用。 所以它被用在后端執行的代碼中,在 Cloud Function 平台上。firebase.database()
,配合 Client JavaScript SDK。 它用於獲取firebase.database.Reference
的實例,以便從/向 Firebase 實時數據庫讀取/寫入數據。所以這完全取決於您計划在哪里執行代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.