Callable

  • database(app?: App):Database
  • Gets theDatabase service for thedefault app or a given app.

    firebase.database() can be called with no arguments to access the defaultapp'sDatabase service or asfirebase.database(app) to access theDatabase service associated with aspecific app.

    firebase.database is also a namespace that can be used to access globalconstants and methods associated with theDatabase service.

    example
    // Get the Database service for the default appvar defaultDatabase = firebase.database();
    example
    // Get the Database service for a specific appvar otherDatabase = firebase.database(app);
    namespace

    Parameters

    • Optional app:App

      Optional app whose Database service toreturn. If not provided, the default Database service will be returned.

    ReturnsDatabase

    The default Database service if no appis provided or the Database service associated with the provided app.

Index

Type aliases

EmulatorMockTokenOptions

EmulatorMockTokenOptions:EmulatorMockTokenOptions

EventType

EventType:"value" |"child_added" |"child_changed" |"child_moved" |"child_removed"

Functions

enableLogging

  • enableLogging(logger?: boolean |((astring) =>any), persistent?: boolean):any
  • Logs debugging information to the console.

    example
    // Enable loggingfirebase.database.enableLogging(true);
    example
    // Disable loggingfirebase.database.enableLogging(false);
    example
    // Enable logging across page refreshesfirebase.database.enableLogging(true,true);
    example
    // Provide custom logger which prefixes log statements with "[FIREBASE]"firebase.database.enableLogging(function(message){console.log("[FIREBASE]", message);});

    Parameters

    • Optional logger:boolean |((a:string) =>any)

      Enables logging iftrue;disables logging iffalse. You can also provide a custom logger functionto control how things get logged.

    • Optional persistent:boolean

      Remembers the logging state between pagerefreshes iftrue.

    Returnsany

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 2023-09-28 UTC.