FQuery Class Reference

Inherits from NSObject
Declared in FQuery.h

Overview

An FQuery instance represents a query over the data at a particular location.

You create one by calling one of the query methods (queryStartingAtPriority:, queryEndingAtPriority:, etc.) on a Firebase reference. The query methods can be chained to further specify the data you are interested in observing

Attaching observers to read data

– observeEventType:withBlock:

observeEventType:withBlock: is used to listen for data changes at a particular location. This is the primary way to read data from a Firebase location. Your block will be triggered for the initial data and again whenever the data changes.

- (FirebaseHandle)observeEventType:(FEventType)eventType withBlock:(void ( ^ ) ( FDataSnapshot *snapshot ))block

Parameters

eventType

The type of event to listen for.

block

The block that should be called with initial data and updates.

Return Value

A handle used to unregister this block later using removeObserverWithHandle:

Discussion

observeEventType:withBlock: is used to listen for data changes at a particular location. This is the primary way to read data from a Firebase location. Your block will be triggered for the initial data and again whenever the data changes.

Use removeObserverWithHandle: to stop receiving updates.

Declared In

FQuery.h

– observeEventType:andPreviousSiblingKeyWithBlock:

observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. This is the primary way to read data from a Firebase location. Your block will be triggered for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.

- (FirebaseHandle)observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void ( ^ ) ( FDataSnapshot *snapshot , NSString *prevKey ))block

Parameters

eventType

The type of event to listen for.

block

The block that should be called with initial data and updates, as well as the previous child’s key.

Return Value

A handle used to unregister this block later using removeObserverWithHandle:

Discussion

observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. This is the primary way to read data from a Firebase location. Your block will be triggered for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.

Use removeObserverWithHandle: to stop receiving updates.

Declared In

FQuery.h

– observeEventType:withBlock:withCancelBlock:

observeEventType:withBlock: is used to listen for data changes at a particular location. This is the primary way to read data from a Firebase location. Your block will be triggered for the initial data and again whenever the data changes.

- (FirebaseHandle)observeEventType:(FEventType)eventType withBlock:(void ( ^ ) ( FDataSnapshot *snapshot ))block withCancelBlock:(void ( ^ ) ( NSError *error ))cancelBlock

Parameters

eventType

The type of event to listen for.

block

The block that should be called with initial data and updates.

cancelBlock

The block that should be called if this client no longer has permission to receive these events

Return Value

A handle used to unregister this block later using removeObserverWithHandle:

Discussion

observeEventType:withBlock: is used to listen for data changes at a particular location. This is the primary way to read data from a Firebase location. Your block will be triggered for the initial data and again whenever the data changes.

The cancelBlock will be called if you will no longer receive new events due to no longer having permission.

Use removeObserverWithHandle: to stop receiving updates.

Declared In

FQuery.h

– observeEventType:andPreviousSiblingKeyWithBlock:withCancelBlock:

observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. This is the primary way to read data from a Firebase location. Your block will be triggered for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.

- (FirebaseHandle)observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void ( ^ ) ( FDataSnapshot *snapshot , NSString *prevKey ))block withCancelBlock:(void ( ^ ) ( NSError *error ))cancelBlock

Parameters

eventType

The type of event to listen for.

block

The block that should be called with initial data and updates, as well as the previous child’s key.

cancelBlock

The block that should be called if this client no longer has permission to receive these events

Return Value

A handle used to unregister this block later using removeObserverWithHandle:

Discussion

observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. This is the primary way to read data from a Firebase location. Your block will be triggered for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.

The cancelBlock will be called if you will no longer receive new events due to no longer having permission.

Use removeObserverWithHandle: to stop receiving updates.

Declared In

FQuery.h

– observeSingleEventOfType:withBlock:

This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned.

- (void)observeSingleEventOfType:(FEventType)eventType withBlock:(void ( ^ ) ( FDataSnapshot *snapshot ))block

Parameters

eventType

The type of event to listen for.

block

The block that should be called with initial data and updates.

Discussion

This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned.

Declared In

FQuery.h

– observeSingleEventOfType:andPreviousSiblingKeyWithBlock:

This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.

- (void)observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void ( ^ ) ( FDataSnapshot *snapshot , NSString *prevKey ))block

Parameters

eventType

The type of event to listen for.

block

The block that should be called with initial data and updates.

Discussion

This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.

Declared In

FQuery.h

– observeSingleEventOfType:withBlock:withCancelBlock:

This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned.

- (void)observeSingleEventOfType:(FEventType)eventType withBlock:(void ( ^ ) ( FDataSnapshot *snapshot ))block withCancelBlock:(void ( ^ ) ( NSError *error ))cancelBlock

Parameters

eventType

The type of event to listen for.

block

The block that should be called with initial data and updates.

cancelBlock

The block that will be called if you don’t have permission to access this data

Discussion

This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned.

The cancelBlock will be called if you do not have permission to read data at this location.

Declared In

FQuery.h

– observeSingleEventOfType:andPreviousSiblingKeyWithBlock:withCancelBlock:

This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.

- (void)observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void ( ^ ) ( FDataSnapshot *snapshot , NSString *prevKey ))block withCancelBlock:(void ( ^ ) ( NSError *error ))cancelBlock

Parameters

eventType

The type of event to listen for.

block

The block that should be called with initial data and updates.

cancelBlock

The block that will be called if you don’t have permission to access this data

Discussion

This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.

The cancelBlock will be called if you do not have permission to read data at this location.

Declared In

FQuery.h

Detaching observers

– removeObserverWithHandle:

Detach a block previously attached with observeEventType:withBlock:.

- (void)removeObserverWithHandle:(FirebaseHandle)handle

Parameters

handle

The handle returned by the call to observeEventType:withBlock: which we are trying to remove.

Discussion

Detach a block previously attached with observeEventType:withBlock:.

Declared In

FQuery.h

– removeAllObservers

Detach all blocks previously attached to this Firebase location with observeEventType:withBlock:

- (void)removeAllObservers

Discussion

Detach all blocks previously attached to this Firebase location with observeEventType:withBlock:

Declared In

FQuery.h

– keepSynced:

By calling keepSynced:YES on a 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.

- (void)keepSynced:(BOOL)keepSynced

Parameters

keepSynced

Pass YES to keep this location synchronized, pass NO to stop synchronization.

Discussion

By calling keepSynced:YES on a 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.

Declared In

FQuery.h

Querying and limiting

– queryStartingAtPriority:

This method is deprecated in favor of using queryStartingAtValue:. This can be used with queryOrderedByPriority to query by priority.

- (FQuery *)queryStartingAtPriority:(id)startPriority

Parameters

startPriority

The lower bound, inclusive, for the priority of data visible to the returned FQuery

Return Value

An FQuery instance, limited to data with priority greater than or equal to startPriority

Discussion

This method is deprecated in favor of using queryStartingAtValue:. This can be used with queryOrderedByPriority to query by priority.

queryStartingAtPriority: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryStartingAtPriority: will respond to events at nodes with a priority greater than or equal to startPriority

Declared In

FQuery.h

– queryStartingAtPriority:andChildName:

This method is deprecated in favor of using queryStartingAtValue:childKey:. This can be used with queryOrderedByPriority to query by priority.

- (FQuery *)queryStartingAtPriority:(id)startPriority andChildName:(NSString *)childName

Parameters

startPriority

The lower bound, inclusive, for the priority of data visible to the returned FQuery

childName

The lower bound, inclusive, for the name of nodes with priority equal to startPriority

Return Value

An FQuery instance, limited to data with priority greater than or equal to startPriority

Discussion

This method is deprecated in favor of using queryStartingAtValue:childKey:. This can be used with queryOrderedByPriority to query by priority.

queryStartingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryStartingAtPriority:andChildName will respond to events at nodes with a priority greater than startPriority, or equal to startPriority and with a name greater than or equal to childName

Declared In

FQuery.h

– queryEndingAtPriority:

This method is deprecated in favor of using queryEndingAtValue:. This can be used with queryOrderedByPriority to query by priority.

- (FQuery *)queryEndingAtPriority:(id)endPriority

Parameters

endPriority

The upper bound, inclusive, for the priority of data visible to the returned FQuery

Return Value

An FQuery instance, limited to data with priority less than or equal to endPriority

Discussion

This method is deprecated in favor of using queryEndingAtValue:. This can be used with queryOrderedByPriority to query by priority.

queryEndingAtPriority: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEndingAtPriority: will respond to events at nodes with a priority less than or equal to startPriority and with a name greater than or equal to childName

Declared In

FQuery.h

– queryEndingAtPriority:andChildName:

This method is deprecated in favor of using queryEndingAtValue:childKey:. This can be used with queryOrderedByPriority to query by priority.

- (FQuery *)queryEndingAtPriority:(id)endPriority andChildName:(NSString *)childName

Parameters

endPriority

The upper bound, inclusive, for the priority of data visible to the returned FQuery

childName

The upper bound, inclusive, for the name of nodes with priority equal to endPriority

Return Value

An FQuery instance, limited to data with priority less than endPriority or equal to endPriority and with a name less than or equal to childName

Discussion

This method is deprecated in favor of using queryEndingAtValue:childKey:. This can be used with queryOrderedByPriority to query by priority.

queryEndingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEndingAtPriority:andChildName will respond to events at nodes with a priority less than endPriority, or equal to endPriority and with a name less than or equal to childName

Declared In

FQuery.h

– queryEqualToPriority:

This method is deprecated in favor of using queryEqualToValue:. This can be used with queryOrderedByPriority to query by priority.

- (FQuery *)queryEqualToPriority:(id)priority

Parameters

priority

The priority that the data returned by this FQuery will have

Return Value

An Fquery instance, limited to data with the supplied priority.

Discussion

This method is deprecated in favor of using queryEqualToValue:. This can be used with queryOrderedByPriority to query by priority.

queryEqualToPriority: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEqualToPriority: will respond to events at nodes with a priority equal to supplied argument.

Declared In

FQuery.h

– queryEqualToPriority:andChildName:

This method is deprecated in favor of using queryEqualAtValue:childKey:. This can be used with queryOrderedByPriority to query by priority.

- (FQuery *)queryEqualToPriority:(id)priority andChildName:(NSString *)childName

Parameters

priority

The priority that the data returned by this FQuery will have

childName

The name of nodes with the right priority

Return Value

An FQuery instance, limited to data with the supplied priority and the name.

Discussion

This method is deprecated in favor of using queryEqualAtValue:childKey:. This can be used with queryOrderedByPriority to query by priority.

queryEqualToPriority:andChildName: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEqualToPriority:andChildName will respond to events at nodes with a priority equal to the supplied argument with a name equal to childName. There will be at most one node that matches because child names are unique.

Declared In

FQuery.h

– queryLimitedToNumberOfChildren:

This method is deprecated in favor of using queryLimitedToFirst:limit or queryLimitedToLast:limit instead.

- (FQuery *)queryLimitedToNumberOfChildren:(NSUInteger)limit

Parameters

limit

The upper bound, inclusive, for the number of child nodes to receive events for

Return Value

An FQuery instance, limited to at most limit child nodes.

Discussion

This method is deprecated in favor of using queryLimitedToFirst:limit or queryLimitedToLast:limit instead.

queryLimitedToNumberOfChildren: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryLimitedToNumberOfChildren: will respond to events from at most limit child nodes.

Declared In

FQuery.h

– queryLimitedToFirst:

queryLimitedToFirst: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryLimitedToFirst: will respond to at most the first limit child nodes.

- (FQuery *)queryLimitedToFirst:(NSUInteger)limit

Parameters

limit

The upper bound, inclusive, for the number of child nodes to receive events for

Return Value

An FQuery instance, limited to at most limit child nodes.

Discussion

queryLimitedToFirst: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryLimitedToFirst: will respond to at most the first limit child nodes.

Declared In

FQuery.h

– queryLimitedToLast:

queryLimitedToLast: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryLimitedToLast: will respond to at most the last limit child nodes.

- (FQuery *)queryLimitedToLast:(NSUInteger)limit

Parameters

limit

The upper bound, inclusive, for the number of child nodes to receive events for

Return Value

An FQuery instance, limited to at most limit child nodes.

Discussion

queryLimitedToLast: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryLimitedToLast: will respond to at most the last limit child nodes.

Declared In

FQuery.h

– queryOrderedByChild:

queryOrderBy: is used to generate a reference to a view of the data that’s been sorted by the values of a particular child key. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, or queryEqualToValue:.

- (FQuery *)queryOrderedByChild:(NSString *)key

Parameters

key

The child key to use in ordering data visible to the returned FQuery

Return Value

An FQuery instance, ordered by the values of the specified child key.

Discussion

queryOrderBy: is used to generate a reference to a view of the data that’s been sorted by the values of a particular child key. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, or queryEqualToValue:.

Declared In

FQuery.h

– queryOrderedByKey

queryOrderedByKey: is used to generate a reference to a view of the data that’s been sorted by child key. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, or queryEqualToValue:.

- (FQuery *)queryOrderedByKey

Return Value

An FQuery instance, ordered by child keys.

Discussion

queryOrderedByKey: is used to generate a reference to a view of the data that’s been sorted by child key. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, or queryEqualToValue:.

Declared In

FQuery.h

– queryOrderedByValue

queryOrderedByValue: is used to generate a reference to a view of the data that’s been sorted by child value. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, or queryEqualToValue:.

- (FQuery *)queryOrderedByValue

Return Value

An FQuery instance, ordered by child value.

Discussion

queryOrderedByValue: is used to generate a reference to a view of the data that’s been sorted by child value. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, or queryEqualToValue:.

Declared In

FQuery.h

– queryOrderedByPriority

queryOrderedByPriority: is used to generate a reference to a view of the data that’s been sorted by child priority. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, or queryEqualToValue:.

- (FQuery *)queryOrderedByPriority

Return Value

An FQuery instance, ordered by child priorities.

Discussion

queryOrderedByPriority: is used to generate a reference to a view of the data that’s been sorted by child priority. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, or queryEqualToValue:.

Declared In

FQuery.h

– queryStartingAtValue:

queryStartingAtValue: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryStartingAtValue: will respond to events at nodes with a value greater than or equal to startValue.

- (FQuery *)queryStartingAtValue:(id)startValue

Parameters

startValue

The lower bound, inclusive, for the value of data visible to the returned FQuery

Return Value

An FQuery instance, limited to data with value greater than or equal to startValue

Discussion

queryStartingAtValue: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryStartingAtValue: will respond to events at nodes with a value greater than or equal to startValue.

Declared In

FQuery.h

– queryStartingAtValue:childKey:

queryStartingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryStartingAtValue:childKey will respond to events at nodes with a value greater than startValue, or equal to startValue and with a key greater than or equal to childKey.

- (FQuery *)queryStartingAtValue:(id)startValue childKey:(NSString *)childKey

Parameters

startValue

The lower bound, inclusive, for the value of data visible to the returned FQuery

childKey

The lower bound, inclusive, for the key of nodes with value equal to startValue

Return Value

An FQuery instance, limited to data with value greater than or equal to startValue

Discussion

queryStartingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryStartingAtValue:childKey will respond to events at nodes with a value greater than startValue, or equal to startValue and with a key greater than or equal to childKey.

Declared In

FQuery.h

– queryEndingAtValue:

queryEndingAtValue: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEndingAtValue: will respond to events at nodes with a value less than or equal to endValue.

- (FQuery *)queryEndingAtValue:(id)endValue

Parameters

endValue

The upper bound, inclusive, for the value of data visible to the returned FQuery

Return Value

An FQuery instance, limited to data with value less than or equal to endValue

Discussion

queryEndingAtValue: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEndingAtValue: will respond to events at nodes with a value less than or equal to endValue.

Declared In

FQuery.h

– queryEndingAtValue:childKey:

queryEndingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEndingAtValue:childKey will respond to events at nodes with a value less than endValue, or equal to endValue and with a key less than or equal to childKey.

- (FQuery *)queryEndingAtValue:(id)endValue childKey:(NSString *)childKey

Parameters

endValue

The upper bound, inclusive, for the value of data visible to the returned FQuery

childKey

The upper bound, inclusive, for the key of nodes with value equal to endValue

Return Value

An FQuery instance, limited to data with value less than or equal to endValue

Discussion

queryEndingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEndingAtValue:childKey will respond to events at nodes with a value less than endValue, or equal to endValue and with a key less than or equal to childKey.

Declared In

FQuery.h

– queryEqualToValue:

queryEqualToValue: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEqualToValue: will respond to events at nodes with a value equal to the supplied argument.

- (FQuery *)queryEqualToValue:(id)value

Parameters

value

The value that the data returned by this FQuery will have

Return Value

An Fquery instance, limited to data with the supplied value.

Discussion

queryEqualToValue: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEqualToValue: will respond to events at nodes with a value equal to the supplied argument.

Declared In

FQuery.h

– queryEqualToValue:childKey:

queryEqualToValue:childKey: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEqualToValue:childKey will respond to events at nodes with a value equal to the supplied argument with a name equal to childKey. There will be at most one node that matches because child keys are unique.

- (FQuery *)queryEqualToValue:(id)value childKey:(NSString *)childKey

Parameters

value

The value that the data returned by this FQuery will have

childKey

The name of nodes with the right value

Return Value

An FQuery instance, limited to data with the supplied value and the key.

Discussion

queryEqualToValue:childKey: is used to generate a reference to a limited view of the data at this location. The FQuery instance returned by queryEqualToValue:childKey will respond to events at nodes with a value equal to the supplied argument with a name equal to childKey. There will be at most one node that matches because child keys are unique.

Declared In

FQuery.h

Properties

  ref

Get a Firebase reference for the location that this data came from

@property (nonatomic, readonly, strong) Firebase *ref

Return Value

A Firebase instance for the location of this data

Discussion

Get a Firebase reference for the location that this data came from

Declared In

FQuery.h