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.
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.
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.
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 appconstdefaultDatabase=getDatabase();
Example 2
// Get the Database service for a specific appconstotherDatabase=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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-21 UTC."],[],[],null,["# firebase-admin.database package\n\nExternal API Re-exports\n-----------------------\n\nThe following externally defined APIs are re-exported from this module entry point for convenience.\n\n| Symbol | Description |\n|-----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|\n| [DataSnapshot](https://firebase.google.com/docs/reference/js/v8/firebase.database.DataSnapshot) | `DataSnapshot` type from the `@firebase/database-compat` package. |\n| [EventType](https://firebase.google.com/docs/reference/js/v8/firebase.database#eventtype) | `EventType` type from the `@firebase/database-compat` package. |\n| [OnDisconnect](https://firebase.google.com/docs/reference/js/v8/firebase.database.OnDisconnect) | `OnDisconnect` type from the `@firebase/database-compat` package. |\n| [Query](https://firebase.google.com/docs/reference/js/v8/firebase.database.Query) | `Query` type from the `@firebase/database-compat` package. |\n| [Reference](https://firebase.google.com/docs/reference/js/v8/firebase.database.Reference) | `Reference` type from the `@firebase/database-compat` package. |\n| [ThenableReference](https://firebase.google.com/docs/reference/js/v8/firebase.database.ThenableReference) | `ThenableReference` type from the `@firebase/database-compat` package. |\n\nFirebase Realtime Database.\n\nFunctions\n---------\n\n| Function | Description |\n|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [getDatabase(app)](./firebase-admin.database.md#getdatabase_8a40afc) | Gets the [Database](./firebase-admin.database.database.md#database_interface) 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. |\n| [getDatabaseWithUrl(url, app)](./firebase-admin.database.md#getdatabasewithurl_19a3502) | Gets the [Database](./firebase-admin.database.database.md#database_interface) service for the default app or a given app.`getDatabaseWithUrl()` can be called with no arguments to access the default app's [Database](./firebase-admin.database.database.md#database_interface) service or as `getDatabaseWithUrl(app)` to access the [Database](./firebase-admin.database.database.md#database_interface) service associated with a specific app. |\n\nClasses\n-------\n\n| Class | Description |\n|---------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|\n| [FirebaseDatabaseError](./firebase-admin.database.firebasedatabaseerror.md#firebasedatabaseerror_class) | Firebase Database error code structure. This extends FirebaseError. |\n\nInterfaces\n----------\n\n| Interface | Description |\n|----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Database](./firebase-admin.database.database.md#database_interface) | The Firebase Database service interface. Extends the [Database](https://firebase.google.com/docs/reference/js/v8/firebase.database.Database) interface provided by the `@firebase/database-compat` package. |\n\nVariables\n---------\n\n| Variable | Description |\n|-------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [enableLogging](./firebase-admin.database.md#enablelogging) | [enableLogging](https://firebase.google.com/docs/reference/js/v8/firebase.database#enablelogging) function from the `@firebase/database-compat` package. |\n| [ServerValue](./firebase-admin.database.md#servervalue) | [ServerValue](https://firebase.google.com/docs/reference/js/v8/firebase.database.ServerValue) constant from the `@firebase/database-compat` package. |\n\ngetDatabase(app)\n----------------\n\nGets the [Database](./firebase-admin.database.database.md#database_interface) service for the default app or a given app.\n\n`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.\n\n**Signature:** \n\n export declare function getDatabase(app?: App): Database;\n\n### Parameters\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| app | App | |\n\n**Returns:**\n\n[Database](./firebase-admin.database.database.md#database_interface)\n\nThe default `Database` service if no app is provided or the `Database` service associated with the provided app.\n\n### Example 1\n\n // Get the Database service for the default app\n const defaultDatabase = getDatabase();\n\n### Example 2\n\n // Get the Database service for a specific app\n const otherDatabase = getDatabase(app);\n\ngetDatabaseWithUrl(url, app)\n----------------------------\n\nGets the [Database](./firebase-admin.database.database.md#database_interface) service for the default app or a given app.\n\n`getDatabaseWithUrl()` can be called with no arguments to access the default app's [Database](./firebase-admin.database.database.md#database_interface) service or as `getDatabaseWithUrl(app)` to access the [Database](./firebase-admin.database.database.md#database_interface) service associated with a specific app.\n\n**Signature:** \n\n export declare function getDatabaseWithUrl(url: string, app?: App): Database;\n\n### Parameters\n\n| Parameter | Type | Description |\n|-----------|--------|-------------|\n| url | string | |\n| app | App | |\n\n**Returns:**\n\n[Database](./firebase-admin.database.database.md#database_interface)\n\nThe default `Database` service if no app is provided or the `Database` service associated with the provided app.\n\n### Example 1\n\n // Get the Database service for the default app\n const defaultDatabase = getDatabaseWithUrl('https://example.firebaseio.com');\n\n### Example 2\n\n // Get the Database service for a specific app\n const otherDatabase = getDatabaseWithUrl('https://example.firebaseio.com', app);\n\nenableLogging\n-------------\n\n[enableLogging](https://firebase.google.com/docs/reference/js/v8/firebase.database#enablelogging) function from the `@firebase/database-compat` package.\n\n**Signature:** \n\n enableLogging: typeof rtdb.enableLogging\n\nServerValue\n-----------\n\n[ServerValue](https://firebase.google.com/docs/reference/js/v8/firebase.database.ServerValue) constant from the `@firebase/database-compat` package.\n\n**Signature:** \n\n ServerValue: rtdb.ServerValue"]]