firebase-admin.database package

外部 API 重新匯出

為方便起見,下列外部定義的 API 會從這個模組進入點重新匯出。

符號 說明
資料快照 來自 @firebase/database-compat 套件的 DataSnapshot 類型。
EventType 來自 @firebase/database-compat 套件的 EventType 類型。
開啟中斷連線 來自 @firebase/database-compat 套件的 OnDisconnect 類型。
查詢 來自 @firebase/database-compat 套件的 Query 類型。
參考資料 來自 @firebase/database-compat 套件的 Reference 類型。
NextableReference 來自 @firebase/database-compat 套件的 ThenableReference 類型。

Firebase 即時資料庫。

函式

函式 說明
getDatabase(應用程式) 取得預設應用程式或特定應用程式的 Database 服務。getDatabase() 可以在沒有引數的情況下呼叫 getDatabase(),藉此存取預設應用程式的 Database 服務,或者做為 getDatabase(app),以存取與特定應用程式相關聯的 Database 服務。
getDatabaseWithUrl(網址、應用程式) 取得預設應用程式或特定應用程式的 Database 服務。getDatabaseWithUrl() 可以在沒有引數的情況下呼叫 getDatabaseWithUrl(),藉此存取預設應用程式的資料庫服務,或使用 getDatabaseWithUrl(app) 存取與特定應用程式相關聯的 資料庫服務。

介面

介面 說明
資料庫 Firebase 資料庫服務介面。擴充 @firebase/database-compat 套件提供的「Database」介面。

變數

變數 說明
enableLogging enableLogging 函式。@firebase/database-compat
伺服器值 @firebase/database-compat 套件中的 ServerValue 常數。

getDatabase(應用程式)

取得預設應用程式或特定應用程式的 Database 服務。

呼叫 getDatabase() 時無需引數,即可存取預設應用程式的 Database 服務,或做為 getDatabase(app) 存取與特定應用程式相關聯的 Database 服務。

簽名:

export declare function getDatabase(app?: App): Database;

參數

參數 類型 說明
app 應用程式

傳回:

資料庫

預設的 Database 服務 (如未提供應用程式),或與所提供應用程式相關聯的 Database 服務。

範例 1

// Get the Database service for the default app
const defaultDatabase = getDatabase();

範例 2

// Get the Database service for a specific app
const otherDatabase = getDatabase(app);

getDatabaseWithUrl(網址、應用程式)

取得預設應用程式或特定應用程式的 Database 服務。

getDatabaseWithUrl()可在不使用引數的情況下呼叫,來存取預設應用程式的資料庫服務或getDatabaseWithUrl(app)服務,以存取與特定應用程式相關聯的資料庫服務。

簽名:

export declare function getDatabaseWithUrl(url: string, app?: App): Database;

參數

參數 類型 說明
網址 字串
app 應用程式

傳回:

資料庫

預設的 Database 服務 (如未提供應用程式),或與所提供應用程式相關聯的 Database 服務。

範例 1

// Get the Database service for the default app
const defaultDatabase = getDatabaseWithUrl('https://example.firebaseio.com');

範例 2

// Get the Database service for a specific app
const otherDatabase = getDatabaseWithUrl('https://example.firebaseio.com', app);

enableLogging

enableLogging 函式。@firebase/database-compat

簽名:

enableLogging: typeof rtdb.enableLogging

伺服器值

@firebase/database-compat 套件中的 ServerValue 常數。

簽名:

ServerValue: rtdb.ServerValue