admin. database
database
database(app) returns admin.database.Database
Gets the Database service for the default app or a given app.
admin.database() can be called with no arguments to access the default app's Database service or as
admin.database(app) to access the
Database service associated with a specific app.
admin.database is also a namespace that can be used to access global constants and methods associated with the Database service.
Parameter |
|
|---|---|
|
app |
Optional Optional app whose Value must not be null. |
- Returns
-
non-null admin.database.DatabaseThe defaultDatabaseservice if no app is provided or theDatabaseservice associated with the provided app.
Examples
// Get the Database service for the default app
var defaultDatabase = admin.database();
// Get the Database service for a specific app
var otherDatabase = admin.database(app);
Interfaces
Database
DataSnapshot
OnDisconnect
Query
Reference
ThenableReference
Property
ServerValue
{TIMESTAMP: non-null Object}
A placeholder value for auto-populating the current timestamp (time since the Unix epoch, in milliseconds) as determined by the Firebase servers.
Example
var sessionsRef = admin.database().ref("sessions");
sessionsRef.push({
startedAt: admin.database.ServerValue.TIMESTAMP
});
Method
enableLogging
enableLogging(logger, persistent)
Logs debugging information to the console.
Parameter |
|
|---|---|
|
logger |
Optional (boolean or function(string)) Enables logging if |
|
persistent |
Optional boolean Remembers the logging state between page refreshes if |
Examples
// Enable logging
admin.database.enableLogging(true);
// Disable logging
admin.database.enableLogging(false);
// Enable logging across page refreshes
admin.database.enableLogging(true, true);
// Provide custom logger which prefixes log statements with "[FIREBASE]"
firebase.database.enableLogging(function(message) {
console.log("[FIREBASE]", message);
});

