firebase-admin.database package

External API Re-exports

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

SymbolDescription
DataSnapshotDataSnapshot type from the@firebase/database-compat package.
EventTypeEventType type from the@firebase/database-compat package.
OnDisconnectOnDisconnect type from the@firebase/database-compat package.
QueryQuery type from the@firebase/database-compat package.
ReferenceReference type from the@firebase/database-compat package.
ThenableReferenceThenableReference type from the@firebase/database-compat package.

Firebase Realtime Database.

Functions

FunctionDescription
getDatabase(app)Gets theDatabase service for the default app or a given app.getDatabase() can be called with no arguments to access the default app'sDatabase service or asgetDatabase(app) to access theDatabase service associated with a specific app.
getDatabaseWithUrl(url, app)Gets theDatabase service for the default app or a given app.getDatabaseWithUrl() can be called with no arguments to access the default app'sDatabase service or asgetDatabaseWithUrl(app) to access theDatabase service associated with a specific app.

Classes

ClassDescription
FirebaseDatabaseErrorFirebase Database error code structure. This extends FirebaseError.

Interfaces

InterfaceDescription
DatabaseThe Firebase Database service interface. Extends theDatabase interface provided by the@firebase/database-compat package.

Variables

VariableDescription
enableLoggingenableLogging function from the@firebase/database-compat package.
ServerValueServerValue constant from the@firebase/database-compat package.

getDatabase(app)

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

getDatabase() can be called with no arguments to access the default app'sDatabase service or asgetDatabase(app) to access theDatabase service associated with a specific app.

Signature:

exportdeclarefunctiongetDatabase(app?:App):Database;

Parameters

ParameterTypeDescription
appApp

Returns:

Database

The defaultDatabase service if no app is provided or theDatabase service associated with the provided app.

Example 1

// Get the Database service for the default appconstdefaultDatabase=getDatabase();

Example 2

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

getDatabaseWithUrl(url, app)

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

getDatabaseWithUrl() can be called with no arguments to access the default app'sDatabase service or asgetDatabaseWithUrl(app) to access theDatabase service associated with a specific app.

Signature:

exportdeclarefunctiongetDatabaseWithUrl(url:string,app?:App):Database;

Parameters

ParameterTypeDescription
urlstring
appApp

Returns:

Database

The defaultDatabase service if no app is provided or theDatabase service associated with the provided app.

Example 1

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

Example 2

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

enableLogging

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

Signature:

enableLogging:typeofrtdb.enableLogging

ServerValue

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

Signature:

ServerValue:rtdb.ServerValue

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-05-21 UTC.