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 |
|
AddValueListener
void AddValueListener( ValueListener *listener )
Adds a listener that will be called immediately and then again any time the data changes.
Details | |||
---|---|---|---|
Parameters |
|
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 |
|
||
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 |
|
||||
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 |
|
||
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, tvOS and desktop. Please use EqualTo(Variant order_value) instead.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A Query in this same location, filtering out child nodes that have a different sort value than the sort value specified, and containing at most one child with the exact key specified.
|
GetReference
DatabaseReference GetReference() const
Gets a DatabaseReference corresponding to the given location.
Details | |
---|---|
Returns |
A DatabaseReference corresponding to the same location as the Query, but without any of the ordering or filtering parameters.
|
GetValue
Future< DataSnapshot > GetValue()
Gets the value of the query for the given location a single time.
This is an asynchronous operation which takes time to execute, and uses firebase::Future to return its result.
Details | |
---|---|
Returns |
A Future result, which will complete when the operation either succeeds or fails. On this Future's completion, if its Error is kErrorNone, the operation succeeded, and the DataSnapshot contains the data in this location.
|
GetValueLastResult
Future< DataSnapshot > GetValueLastResult()
Gets the result of the most recent call to GetValue().
Details | |
---|---|
Returns |
Result of the most recent call to GetValue().
|
LimitToFirst
Query LimitToFirst( size_t limit )
Gets a Query limited to only the first results.
Limits the query to reference only the first N child nodes, using the given OrderBy directive (or priority as default).
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A Query in this same location, limited to the specified number of children (taken from the beginning of the sorted list).
|
LimitToLast
Query LimitToLast( size_t limit )
OrderByChild
Query OrderByChild( const char *path )
Gets a query in which child nodes are ordered by the values of the specified path.
Any previous OrderBy directive will be replaced in the returned Query.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A Query in this same location, with the children are sorted by the value of their own child specified here.
|
OrderByChild
Query OrderByChild( const std::string & path )
Gets a query in which child nodes are ordered by the values of the specified path.
Any previous OrderBy directive will be replaced in the returned Query.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A Query in this same location, with the children are sorted by the value of their own child specified here.
|
OrderByKey
Query OrderByKey()
OrderByPriority
Query OrderByPriority()
OrderByValue
Query OrderByValue()
Create a query in which nodes are ordered by their value.
Details | |
---|---|
Returns |
A Query in this same location, with the children are sorted by their value.
|
Query
Query()
Query
Query( const Query & query )
Copy constructor.
Queries can be copied. Copies exist independently of each other.
RemoveAllChildListeners
void RemoveAllChildListeners()
Removes all child listeners that were added by AddChildListener().
RemoveAllValueListeners
void RemoveAllValueListeners()
Removes all value listeners that were added with AddValueListener().
RemoveChildListener
void RemoveChildListener( ChildListener *listener )
Removes a listener that was previously added with AddChildListener().
Details | |||
---|---|---|---|
Parameters |
|
RemoveValueListener
void RemoveValueListener( ValueListener *listener )
Removes a listener that was previously added with AddValueListener().
Details | |||
---|---|---|---|
Parameters |
|
SetKeepSynchronized
void SetKeepSynchronized( bool keep_sync )
Sets whether this location's data should be kept in sync even if there are no active Listeners.
By calling SetKeepSynchronized(true) on a given database location, the data for that location will automatically be downloaded and kept in sync, even when no listeners are attached for that location. Additionally, while a location is kept synced, it will not be evicted from the persistent disk cache.
Details | |||
---|---|---|---|
Parameters |
|
StartAt
Query StartAt( Variant order_value )
Get a Query constrained to nodes with the given sort value or higher.
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 greater than or equal to the given value, using the given OrderBy directive (or priority as the default).
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A Query in this same location, filtering out child nodes that have a lower sort value than the sort value specified.
|
StartAt
Query 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.
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 greater than or equal to the given value, using the given OrderBy directive (or priority as default), and additionally only child nodes with a key greater than or equal to the given key.
Known issue This currently does not work properly on all platforms. Please use StartAt(Variant order_value) instead.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A Query in this same location, filtering out child nodes that have a lower sort value than the sort value specified, or a lower key than the key specified.
|
is_valid
virtual bool is_valid() const
Returns true if this query is valid, false if it is not valid.
An invalid query could be returned by, say, attempting to OrderBy two different items, or calling OrderByChild() with an empty path, or by constructing a Query with the default constructor. If a Query is invalid, attempting to add more constraints will also result in an invalid Query.
Details | |
---|---|
Returns |
true if this query is valid, false if this query is invalid.
|
operator=
Query & operator=( const Query & query )
Copy assignment operator.
Queries can be copied. Copies exist independently of each other.
~Query
virtual ~Query()
Required virtual destructor.