Go to console

firebase::database::Query

#include <query.h>

The Query class is used for reading data.

Summary

Listeners can be attached, which will be triggered when the data changes.

Inheritance

Direct Known Subclasses:firebase::database::DatabaseReference

Constructors and Destructors

Query()
Default constructor.
Query(const Query & query)
Copy constructor.
Query(Query && query)
Move constructor.
~Query()
Required virtual destructor.

Public functions

AddChildListener(ChildListener *listener)
void
Adds a listener that will be called any time a child is added, removed, modified, or reordered.
AddValueListener(ValueListener *listener)
void
Adds a listener that will be called immediately and then again any time the data changes.
EndAt(Variant order_value)
Get a Query constrained to nodes with the given sort value or lower.
EndAt(Variant order_value, const char *child_key)
Get a Query constrained to nodes with the given sort value or lower, and the given key or lower.
EqualTo(Variant order_value)
Get a Query constrained to nodes with the exact given sort value.
EqualTo(Variant order_value, const char *child_key)
Get a Query constrained to nodes with the exact given sort value, and the exact given key.
GetReference() const
Gets a DatabaseReference corresponding to the given location.
GetValue()
Gets the value of the query for the given location a single time.
GetValueLastResult()
Gets the result of the most recent call to GetValue().
LimitToFirst(size_t limit)
Gets a Query limited to only the first results.
LimitToLast(size_t limit)
Gets a Query limited to only the last results.
OrderByChild(const char *path)
Gets a query in which child nodes are ordered by the values of the specified path.
OrderByChild(const std::string & path)
Gets a query in which child nodes are ordered by the values of the specified path.
OrderByKey()
Gets a query in which child nodes are ordered by their keys.
OrderByPriority()
Gets a query in which child nodes are ordered by their priority.
OrderByValue()
Create a query in which nodes are ordered by their value.
RemoveAllChildListeners()
void
Removes all child listeners that were added by AddChildListener().
RemoveAllValueListeners()
void
Removes all value listeners that were added with AddValueListener().
RemoveChildListener(ChildListener *listener)
void
Removes a listener that was previously added with AddChildListener().
RemoveValueListener(ValueListener *listener)
void
Removes a listener that was previously added with AddValueListener().
SetKeepSynchronized(bool keep_sync)
void
Sets whether this location's data should be kept in sync even if there are no active Listeners.
StartAt(Variant order_value)
Get a Query constrained to nodes with the given sort value or higher.
StartAt(Variant order_value, const char *child_key)
Get a Query constrained to nodes with the given sort value or higher, and the given key or higher.
is_valid() const
virtual bool
Returns true if this query is valid, false if it is not valid.
operator=(const Query & query)
Query &
Copy assignment operator.
operator=(Query && query)
Query &
Move assignment operator.

Public functions

AddChildListener

void AddChildListener(
  ChildListener *listener
)

Adds a listener that will be called any time a child is added, removed, modified, or reordered.

Details
Parameters
listener
A ChildListener instance, which must remain in memory until you remove the listener from the Query.

AddValueListener

void AddValueListener(
  ValueListener *listener
)

Adds a listener that will be called immediately and then again any time the data changes.

Details
Parameters
listener
A ValueListener instance, which must remain in memory until you remove the listener from the Query.

EndAt

Query EndAt(
  Variant order_value
)

Get a Query constrained to nodes with the given sort value or lower.

This method is used to generate a reference to a limited view of the data at this location. The Query returned will only refer to child nodes with a value less than or equal to the given value, using the given OrderBy directive (or priority as default).

Details
Parameters
order_value
The highest sort value the Query should refer to.
Returns
A Query in this same location, filtering out child nodes that have a higher sort value or key than the sort value or key specified.

EndAt

Query EndAt(
  Variant order_value,
  const char *child_key
)

Get a Query constrained to nodes with the given sort value or lower, and the given key or lower.

This method is used to generate a reference to a limited view of the data at this location. The Query returned will only refer to child nodes with a value less than or equal to the given value, using the given OrderBy directive (or priority as default), and additionally only child nodes with a key less than or equal to the given key.

Known issue This currently does not work properly on all platforms. Please use EndAt(Variant order_value) instead.

Details
Parameters
order_value
The highest sort value the Query should include.
child_key
The highest key the Query should include.
Returns
A Query in this same location, filtering out child nodes that have a higher sort value than the sort value specified, or a higher key than the key specified.

EqualTo

Query EqualTo(
  Variant order_value
)

Get a Query constrained to nodes with the exact given sort value.

This method is used to create a query constrained to only return child nodes with the given value, using the given OrderBy directive (or priority as default).

Details
Parameters
order_value
The exact sort value the Query should include.
Returns
A Query in this same location, filtering out child nodes that have a different sort value than the sort value specified.

EqualTo

Query EqualTo(
  Variant order_value,
  const char *child_key
)

Get a Query constrained to nodes with the exact given sort value, and the exact given key.

This method is used to create a query constrained to only return the child node with the given value, using the given OrderBy directive (or priority as default), and the given key. Note that there is at most one such child as child key names are unique.

Known issue This currently does not work properly on iOS and desktop. Please use EqualTo(Variant order_value) instead.

Details
Parameters
order_value
The exact sort value the Query should i