firebase-admin.database package

External API Re-exports

The following externally defined APIs are re-exported from this module entry point for convenience.

Symbol Description
DataSnapshot DataSnapshot type from the @firebase/database-compat package.
EventType EventType type from the @firebase/database-compat package.
OnDisconnect OnDisconnect type from the @firebase/database-compat package.
Query Query type from the @firebase/database-compat package.
Reference Reference type from the @firebase/database-compat package.
ThenableReference ThenableReference type from the @firebase/database-compat package.

Firebase Realtime Database.

Functions

Function Description
getDatabase(app) Gets the Database service for the default app or a given app.getDatabase() can be called with no arguments to access the default app's Database service or as getDatabase(app) to access the Database service associated with a specific app.
getDatabaseWithUrl(url, app) Gets the Database service for the default app or a given app.getDatabaseWithUrl() can be called with no arguments to access the default app's Database service or as getDatabaseWithUrl(app) to access the Database service associated with a specific app.

Classes

Class Description
FirebaseDatabaseError Firebase Database error code structure. This extends FirebaseError.

Interfaces

Interface Description
Database The Firebase Database service interface. Extends the Database interface provided by the @firebase/database-compat package.

Variables

Variable Description
enableLogging enableLogging function from the @firebase/database-compat package.
ServerValue ServerValue constant from the @firebase/database-compat package.

getDatabase(app)

Gets the Database service for the default app or a given app.

getDatabase() can be called with no arguments to access the default app's Database service or as getDatabase(app) to access the Database service associated with a specific app.

Signature:

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

Parameters

Parameter Type Description
app App

Returns:

Database

The default Database service if no app is provided or the Database service associated with the provided app.

Example 1

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

Example 2

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

getDatabaseWithUrl(url, app)

Gets the Database service for the default app or a given app.

getDatabaseWithUrl() can be called with no arguments to access the default app's Database service or as getDatabaseWithUrl(app) to access the Database service associated with a specific app.

Signature:

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

Parameters

Parameter Type Description
url string
app App

Returns:

Database

The default Database service if no app is provided or the Database service associated with the provided app.

Example 1

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

Example 2

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

enableLogging

enableLogging function from the @firebase/database-compat package.

Signature:

enableLogging: typeof rtdb.enableLogging

ServerValue

ServerValue constant from the @firebase/database-compat package.

Signature:

ServerValue: rtdb.ServerValue