The app associated with the current
Database service instance.
var app = database.app;
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
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
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.
ref(path) returns admin.database.Reference
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.
Optional path representing the location the returned
non-null admin.database.ReferenceIf a path is provided, a
Referencepointing to the provided path. Otherwise, a
Referencepointing to the root of the Database.
// Get a reference to the root of the Database var rootRef = admin.database.ref();
// Get a reference to the /users/ada node var adaRef = admin.database().ref("users/ada"); // The above is shorthand for the following operations: //var rootRef = admin.database().ref(); //var adaRef = rootRef.child("users/ada");
refFromURL(url) returns admin.database.Reference
Reference representing the location in the Database corresponding to the provided Firebase URL.
An exception is thrown if the URL is not a valid Firebase Database URL or it has a different domain than the current
Note that all query parameters (
limitToLast, etc.) are ignored and are not applied to the returned
The Firebase URL at which the returned
Referencepointing to the provided Firebase URL.
// Get a reference to the root of the Database var rootRef = admin.database().ref("https://<DATABASE_NAME>.firebaseio.com");
// Get a reference to the /users/ada node var adaRef = admin.database().ref("https://<DATABASE_NAME>.firebaseio.com/users/ada");