转到控制台

firebase::database::DatabaseReference

#include <database_reference.h>

DatabaseReference represents a particular location in your Database and can be used for reading or writing data to that Database location.

Summary

This class is the starting point for all Database operations. After you've initialized it with a URL, you can use it to read data, write data, and to create new DatabaseReference instances.

Inheritance

Inherits from: firebase::database::Query

Constructors and Destructors

DatabaseReference()
Default constructor.
DatabaseReference(const DatabaseReference & reference)
Copy constructor.
DatabaseReference(DatabaseReference && reference)
Move constructor.
~DatabaseReference()
Required virtual destructor.

Public functions

Child(const char *path) const
Gets a reference to a location relative to this one.
Child(const std::string & path) const
Gets a reference to a location relative to this one.
GetParent() const
Gets the parent of this location, or get this location again if IsRoot().
GetRoot() const
Gets the root of the database.
GoOffline()
void
Manually disconnect Firebase Realtime Database from the server, and disable automatic reconnection.
GoOnline()
void
Manually reestablish connection to the Firebase Realtime Database server and enable automatic reconnection.
OnDisconnect()
Get the disconnect handler, which controls what actions the server will perform to this location's data when this client disconnects.
PushChild() const
Automatically generates a child location, create a reference to it, and returns that reference to it.
RemoveValue()
Future< void >
Removes the value at this location from the database.
RemoveValueLastResult()
Future< void >
Gets the result of the most recent call to RemoveValue();.
RunTransaction(DoTransactionWithContext transaction_function, void *context, bool trigger_local_events)
Run a user-supplied callback function (passing in a context), possibly multiple times, to perform an atomic transaction on the database.
RunTransaction(DoTransactionFunction transaction_function, bool trigger_local_events)
Run a user-supplied callback, possibly multiple times, to perform an atomic transaction on the database.
RunTransaction(DoTransaction transaction_function, bool trigger_local_events)
Run a user-supplied callback function, possibly multiple times, to perform an atomic transaction on the database.
RunTransactionLastResult()
Get the result of the most recent call to RunTransaction().
SetPriority(Variant priority)
Future< void >
Sets the priority of this field, which controls its sort order relative to its siblings.
SetPriorityLastResult()
Future< void >
Gets the result of the most recent call to SetPriority().
SetValue(Variant value)
Future< void >
Sets the data at this location to the given value.
SetValueAndPriority(Variant value, Variant priority)
Future< void >
Sets both the data and priority of this location.
SetValueAndPriorityLastResult()
Future< void >
Get the result of the most recent call to SetValueAndPriority().
SetValueLastResult()
Future< void >
Gets the result of the most recent call to SetValue().
UpdateChildren(Variant values)
Future< void >
Updates the specified child keys to the given values.
UpdateChildren(const std::map< std::string, Variant > & values)
Future< void >
Updates the specified child keys to the given values.
UpdateChildrenLastResult()
Future< void >
Gets the result of the most recent call to either version of UpdateChildren().
database() const
Gets the database to which we refer.
is_root() const
bool
Returns true if this reference refers to the root of the database.
is_valid() const override
virtual bool
Returns true if this reference is valid, false if it is not valid.
key() const
const char *
Gets the string key of this database location.
key_string() const
std::string
Gets the string key of this database location.
operator=(const DatabaseReference & reference)
Copy assignment operator.
operator=(DatabaseReference && reference)
Move assignment operator.
url() const
std::string
Get the absolute URL of this reference.

Public functions

Child

DatabaseReference Child(
  const char *path
) const 

Gets a reference to a location relative to this one.

Details
Parameters
path
Path relative to this snapshot's location. The pointer only needs to be valid during this call.
Returns
Child relative to this location.

Child

DatabaseReference Child(
  const std::string & path
) const 

Gets a reference to a location relative to this one.

Details
Parameters
path
Path relative to this snapshot's location.
Returns
Child relative to this location.

DatabaseReference

 DatabaseReference()

Default constructor.

This creates an invalid DatabaseReference. Attempting to perform any operations on this reference will fail unless a valid DatabaseReference has been assigned to it.

DatabaseReference

 DatabaseReference(
  const DatabaseReference & reference
)

Copy constructor.

It's totally okay (and efficient) to copy DatabaseReference instances, as they simply point to the same location in the database.

Details
Parameters