firebase-admin.database package

外部 API 重新导出

为方便起见,系统将从此模块入口点重新导出以下外部定义的 API。

符号 说明
数据快照 来自 @firebase/database-compat 软件包的 DataSnapshot 类型。
EventType 来自 @firebase/database-compat 软件包的 EventType 类型。
OnDisconnect 来自 @firebase/database-compat 软件包的 OnDisconnect 类型。
查询 来自 @firebase/database-compat 软件包的 Query 类型。
参考文档 来自 @firebase/database-compat 软件包的 Reference 类型。
ThenableReference 来自 @firebase/database-compat 软件包的 ThenableReference 类型。

Firebase Realtime Database。

函数

函数 说明
getDatabase(app) 获取默认应用或指定应用的 数据库服务。可调用getDatabase()(不使用任何参数)来访问默认应用的 Database 服务,或以 getDatabase(app) 的形式调用Database以访问特定的应用。
getDatabaseWithUrl(url, app) 获取默认应用或指定应用的 Database 服务。调用 getDatabaseWithUrl() 时不使用任何参数,以访问默认应用的 Database 服务,或以 getDatabaseWithUrl(app) 的身份访问与特定应用关联的 Database 服务。

接口

接口 说明
数据库 Firebase 数据库服务接口。扩展 @firebase/database-compat 软件包提供的 Database 接口。

变量

变量 说明
enableLogging @firebase/database-compat 软件包中的 enableLogging 函数。
服务器价值 来自 @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(url, app)

获取默认应用或指定应用的 Database 服务。

可以不使用任何参数调用 getDatabaseWithUrl() 以访问默认应用的 Database 服务,或者以 getDatabaseWithUrl(app) 的形式调用,以访问与特定应用关联的 Database 服务。

签名

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

参数

参数 类型 说明
网址 string
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

@firebase/database-compat 软件包中的 enableLogging 函数。

签名

enableLogging: typeof rtdb.enableLogging

ServerValue

来自 @firebase/database-compat 包的 ServerValue 常量。

签名

ServerValue: rtdb.ServerValue