Ir a la consola

firebase::database::Database

#include <database.h>

Entry point for the Firebase Realtime Database C++ SDK.

Summary

To use the SDK, call firebase::database::Database::GetInstance() to obtain an instance of Database, then use GetReference() to obtain references to child paths within the database. From there you can set data via Query::SetValue(), get data via Query::GetValue(), attach listeners, and more.

Constructors and Destructors

~Database()
Destructor for the Database object.

Public static functions

GetInstance(::firebase::App *app, InitResult *init_result_out)
Get an instance of Database corresponding to the given App.
GetInstance(::firebase::App *app, const char *url, InitResult *init_result_out)
Gets an instance of FirebaseDatabase for the specified URL.

Public functions

GetReference() const
Get a DatabaseReference to the root of the database.
GetReference(const char *path) const
Get a DatabaseReference for the specified path.
GetReferenceFromUrl(const char *url) const
Get a DatabaseReference for the provided URL, which must belong to the database URL this instance is already connected to.
GoOffline()
void
Shuts down the connection to the Firebase Realtime Database backend until GoOnline() is called.
GoOnline()
void
Resumes the connection to the Firebase Realtime Database backend after a previous GoOffline() call.
PurgeOutstandingWrites()
void
Purge all pending writes to the Firebase Realtime Database server.
app() const
App *
Get the firebase::App that this Database was created with.
log_level() const
Get the log verbosity of this object.
set_log_level(LogLevel log_level)
void
Set the log verbosity of this object.
set_persistence_enabled(bool enabled)
void
Sets whether pending write data will persist between application exits.
url() const
const char *
Get the URL that this Database was created with.

Public static functions

GetInstance

Database * GetInstance(
  ::firebase::App *app,
  InitResult *init_result_out
)

Get an instance of Database corresponding to the given App.

Firebase Realtime Database uses firebase::App to communicate with Firebase Authentication to authenticate users to the Database server backend.

If you call GetInstance() multiple times with the same App, you will get the same instance of Database.

Details
Parameters
app
Your instance of firebase::App. Firebase Realtime Database will use this to communicate with Firebase Authentication.
init_result_out
Optional: If provided, write the init result here. Will be set to kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device.
Returns
An instance of Database corresponding to the given App.

GetInstance

Database * GetInstance(
  ::firebase::App *app,
  const char *url,
  InitResult *init_result_out
)

Gets an instance of FirebaseDatabase for the specified URL.

If you call GetInstance() multiple times with the same App and URL, you will get the same instance of Database.

Details
Parameters
app
Your instance of firebase::App. Firebase Realtime Database will use this to communicate with Firebase Authentication.
url
The URL of your Firebase Realtime Database. This overrides any url specified in the App options.
init_result_out
Optional: If provided, write the init result here. Will be set to kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device.
Returns
An instance of Database corresponding to the given App and URL.

Public functions

GetReference

DatabaseReference GetReference() const 

Get a DatabaseReference to the root of the database.

Details
Returns
A DatabaseReference to the root of the database.