The app associated with the Database service
instance.
example
var app = database.app;
Methods
goOffline
goOffline
(): any
Disconnects from the server (all Database operations will be completed
offline).
The client automatically maintains a persistent connection to the Database
server, which will remain active indefinitely and reconnect when
disconnected. However, the goOffline() and goOnline() methods may be used
to control the client connection in cases where a persistent connection is
undesirable.
While offline, the client will no longer receive data updates from the
Database. However, all Database operations performed locally will continue to
immediately fire events, allowing your application to continue behaving
normally. Additionally, each operation performed locally will automatically
be queued and retried upon reconnection to the Database server.
To reconnect to the Database and begin receiving remote events, see
goOnline().
example
firebase.database().goOffline();
Returns any
goOnline
goOnline
(): any
Reconnects to the server and synchronizes the offline Database state
with the server state.
This method should be used after disabling the active connection with
goOffline(). Once reconnected, the client will transmit the proper data
and fire the appropriate events so that your client "catches up"
automatically.
Returns a Reference representing the location in the Database
corresponding to the provided path. If no path is provided, the Reference
will point to the root of the Database.
example
// Get a reference to the root of the Databasevar rootRef = firebase.database().ref();
example
// Get a reference to the /users/ada nodevar adaRef = firebase.database().ref("users/ada");
// The above is shorthand for the following operations://var rootRef = firebase.database().ref();//var adaRef = rootRef.child("users/ada");
Parameters
Optional path: string
Optional path representing the location the returned
Reference will point. If not provided, the returned Reference will
point to the root of the Database.
[[["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 2022-07-27 UTC."],[],[],null,["- [firebase](/docs/reference/node/firebase).\n- [database](/docs/reference/node/firebase.database).\n- Database \nThe Firebase Database service interface.\n\nDo not call this constructor directly. Instead, use\n[`firebase.database()`](/docs/reference/node/firebase.database).\n\nSee\n[Installation \\& Setup in JavaScript](https://firebase.google.com/docs/database/web/start/)\nfor a full guide on how to use the Firebase Database service.\n\nIndex\n\nProperties\n\n- [INTERNAL](/docs/reference/node/firebase.database.Database#internal)\n- [app](/docs/reference/node/firebase.database.Database#app)\n\nMethods\n\n- [goOffline](/docs/reference/node/firebase.database.Database#gooffline)\n- [goOnline](/docs/reference/node/firebase.database.Database#goonline)\n- [ref](/docs/reference/node/firebase.database.Database#ref)\n- [refFromURL](/docs/reference/node/firebase.database.Database#reffromurl)\n- [useEmulator](/docs/reference/node/firebase.database.Database#useemulator)\n\nProperties\n\nINTERNAL \nINTERNAL: { forceLongPolling: () =\\\u003e void; forceWebSockets: () =\\\u003e void } \nAdditional methods for debugging and special cases. \n\nType declaration\n\n-\n\n forceLongPolling: () =\\\u003e void \n Force the use of long polling instead of WebSockets. This will be ignored if the WebSocket protocol is used in `databaseURL`.\n -\n - (): void\n\n \u003c!-- --\u003e\n\n -\n\n Returns void\n-\n\n forceWebSockets: () =\\\u003e void \n Force the use of WebSockets instead of long polling.\n -\n - (): void\n\n \u003c!-- --\u003e\n\n -\n\n Returns void\n\napp \napp: [App](/docs/reference/node/firebase.app.App) \nThe [app](/docs/reference/node/firebase.app.App) associated with the `Database` service\ninstance.\n\nexample\n:\n\n var app = database.app;\n\n\nMethods\n\ngoOffline\n\n- goOffline ( ) : any\n- Disconnects from the server (all Database operations will be completed\n offline).\n\n The client automatically maintains a persistent connection to the Database\n server, which will remain active indefinitely and reconnect when\n disconnected. However, the `goOffline()` and `goOnline()` methods may be used\n to control the client connection in cases where a persistent connection is\n undesirable.\n\n While offline, the client will no longer receive data updates from the\n Database. However, all Database operations performed locally will continue to\n immediately fire events, allowing your application to continue behaving\n normally. Additionally, each operation performed locally will automatically\n be queued and retried upon reconnection to the Database server.\n\n To reconnect to the Database and begin receiving remote events, see\n `goOnline()`.\n\n example\n :\n\n firebase.database().goOffline();\n\n\n Returns any\n\ngoOnline\n\n- goOnline ( ) : any\n- Reconnects to the server and synchronizes the offline Database state\n with the server state.\n\n This method should be used after disabling the active connection with\n `goOffline()`. Once reconnected, the client will transmit the proper data\n and fire the appropriate events so that your client \"catches up\"\n automatically.\n\n example\n :\n\n firebase.database().goOnline();\n\n\n Returns any\n\nref\n\n- ref ( path ? : string ) : [Reference](/docs/reference/node/firebase.database.Reference)\n- Returns a `Reference` representing the location in the Database\n corresponding to the provided path. If no path is provided, the `Reference`\n will point to the root of the Database.\n\n example\n :\n\n // Get a reference to the root of the Database\n var rootRef = firebase.database().ref();\n\n\n example\n :\n\n // Get a reference to the /users/ada node\n var adaRef = firebase.database().ref(\"users/ada\");\n // The above is shorthand for the following operations:\n //var rootRef = firebase.database().ref();\n //var adaRef = rootRef.child(\"users/ada\");\n\n\n Parameters\n -\n\n Optional path: string \n Optional path representing the location the returned\n `Reference` will point. If not provided, the returned `Reference` will\n point to the root of the Database.\n\n Returns [Reference](/docs/reference/node/firebase.database.Reference)\n\n If a path is provided, a `Reference`\n pointing to the provided path. Otherwise, a `Reference` pointing to the\n root of the Database.\n\nrefFromURL\n\n- refFromURL ( url : string ) : [Reference](/docs/reference/node/firebase.database.Reference)\n- Returns a `Reference` representing the location in the Database\n corresponding to the provided Firebase URL.\n\n An exception is thrown if the URL is not a valid Firebase Database URL or it\n has a different domain than the current `Database` instance.\n\n Note that all query parameters (`orderBy`, `limitToLast`, etc.) are ignored\n and are not applied to the returned `Reference`.\n\n example\n :\n\n // Get a reference to the root of the Database\n var rootRef = firebase.database().ref(\"https://\u003cDATABASE_NAME\u003e.firebaseio.com\");\n\n\n example\n :\n\n // Get a reference to the /users/ada node\n var adaRef = firebase.database().ref(\"https://\u003cDATABASE_NAME\u003e.firebaseio.com/users/ada\");\n\n\n Parameters\n -\n\n url: string \n The Firebase URL at which the returned `Reference` will\n point.\n\n Returns [Reference](/docs/reference/node/firebase.database.Reference)\n\n A `Reference` pointing to the provided\n Firebase URL.\n\nuseEmulator\n\n- useEmulator ( host : string , port : number , options ? : { mockUserToken ?: [EmulatorMockTokenOptions](/docs/reference/node/firebase.database#emulatormocktokenoptions) \\| string } ) : void\n- Modify this instance to communicate with the Realtime Database emulator.\n\n Note: This method must be called before performing any other operation.\n\n Parameters\n -\n\n host: string \n the emulator host (ex: localhost)\n -\n\n port: number \n the emulator port (ex: 8080)\n -\n\n Optional options: { mockUserToken?: [EmulatorMockTokenOptions](/docs/reference/node/firebase.database#emulatormocktokenoptions) \\| string }\n -\n\n Optional mockUserToken?: [EmulatorMockTokenOptions](/docs/reference/node/firebase.database#emulatormocktokenoptions) \\| string \n the mock auth token to use for unit testing Security Rules\n\nReturns void"]]
The Firebase Database service interface.
Do not call this constructor directly. Instead, use
firebase.database()
.See Installation & Setup in JavaScript for a full guide on how to use the Firebase Database service.