AVQuery Class Reference
Inherits from | NSObject |
---|---|
Declared in | AVQuery.h |
Creating a Query for a Class
+ queryWithClassName:
Returns a AVQuery for a given class.
+ (instancetype)queryWithClassName:(NSString *)className
Parameters
className |
The class to query on. |
---|
Return Value
A AVQuery object.
Discussion
Returns a AVQuery for a given class.
Declared In
AVQuery.h
+ doCloudQueryWithCQL:
使用 CQL 查询
+ (nullable AVCloudQueryResult *)doCloudQueryWithCQL:(NSString *)cql
Parameters
cql |
CQL 字符串 |
---|
Return Value
查询结果
Discussion
使用 CQL 查询
Declared In
AVQuery.h
+ doCloudQueryWithCQL:error:
使用 CQL 查询
+ (nullable AVCloudQueryResult *)doCloudQueryWithCQL:(NSString *)cql error:(NSError **)error
Parameters
cql |
CQL 字符串 |
---|---|
error |
用于返回错误结果 |
Return Value
查询结果
Discussion
使用 CQL 查询
Declared In
AVQuery.h
+ doCloudQueryWithCQL:pvalues:error:
使用 CQL 查询
+ (nullable AVCloudQueryResult *)doCloudQueryWithCQL:(NSString *)cql pvalues:(nullable NSArray *)pvalues error:(NSError **)error
Parameters
cql |
CQL 字符串 |
---|---|
pvalues |
参数列表 |
error |
用于返回错误结果 |
Return Value
查询结果
Discussion
使用 CQL 查询
Declared In
AVQuery.h
+ doCloudQueryInBackgroundWithCQL:callback:
使用 CQL 异步查询
+ (void)doCloudQueryInBackgroundWithCQL:(NSString *)cql callback:(AVCloudQueryCallback)callback
Parameters
cql |
CQL 字符串 |
---|---|
callback |
查询结果回调 |
Discussion
使用 CQL 异步查询
Declared In
AVQuery.h
+ doCloudQueryInBackgroundWithCQL:pvalues:callback:
使用 CQL 异步查询
+ (void)doCloudQueryInBackgroundWithCQL:(NSString *)cql pvalues:(nullable NSArray *)pvalues callback:(AVCloudQueryCallback)callback
Parameters
cql |
CQL 字符串 |
---|---|
pvalues |
参数列表 |
callback |
查询结果回调 |
Discussion
使用 CQL 异步查询
Declared In
AVQuery.h
– initWithClassName:
Initializes the query with a class name.
- (instancetype)initWithClassName:(NSString *)newClassName
Parameters
newClassName |
The class name. |
---|
Discussion
Initializes the query with a class name.
Declared In
AVQuery.h
className
The class name to query for
@property (nonatomic, copy) NSString *className
Discussion
The class name to query for
Declared In
AVQuery.h
Adding Basic Constraints
– includeKey:
Make the query include AVObjects that have a reference stored at the provided key. This has an effect similar to a join. You can use dot notation to specify which fields in the included object are also fetch.
- (void)includeKey:(NSString *)key
Parameters
key |
The key to load child AVObjects for. |
---|
Discussion
Make the query include AVObjects that have a reference stored at the provided key. This has an effect similar to a join. You can use dot notation to specify which fields in the included object are also fetch.
Declared In
AVQuery.h
– selectKeys:
Make the query restrict the fields of the returned AVObjects to include only the provided keys. If this is called multiple times, then all of the keys specified in each of the calls will be included.
- (void)selectKeys:(NSArray *)keys
Parameters
keys |
The keys to include in the result. |
---|
Discussion
Make the query restrict the fields of the returned AVObjects to include only the provided keys. If this is called multiple times, then all of the keys specified in each of the calls will be included.
Declared In
AVQuery.h
– whereKeyExists:
Add a constraint that requires a particular key exists.
- (void)whereKeyExists:(NSString *)key
Parameters
key |
The key that should exist. |
---|
Discussion
Add a constraint that requires a particular key exists.
Declared In
AVQuery.h
– whereKeyDoesNotExist:
Add a constraint that requires a key not exist.
- (void)whereKeyDoesNotExist:(NSString *)key
Parameters
key |
The key that should not exist. |
---|
Discussion
Add a constraint that requires a key not exist.
Declared In
AVQuery.h
– whereKey:equalTo:
Add a constraint to the query that requires a particular key’s object to be equal to the provided object.
- (void)whereKey:(NSString *)key equalTo:(id)object
Parameters
key |
The key to be constrained. |
---|---|
object |
The object that must be equalled. |
Discussion
Add a constraint to the query that requires a particular key’s object to be equal to the provided object.
Declared In
AVQuery.h
– whereKey:lessThan:
Add a constraint to the query that requires a particular key’s object to be less than the provided object.
- (void)whereKey:(NSString *)key lessThan:(id)object
Parameters
key |
The key to be constrained. |
---|---|
object |
The object that provides an upper bound. |
Discussion
Add a constraint to the query that requires a particular key’s object to be less than the provided object.
Declared In
AVQuery.h
– whereKey:lessThanOrEqualTo:
Add a constraint to the query that requires a particular key’s object to be less than or equal to the provided object.
- (void)whereKey:(NSString *)key lessThanOrEqualTo:(id)object
Parameters
key |
The key to be constrained. |
---|---|
object |
The object that must be equalled. |
Discussion
Add a constraint to the query that requires a particular key’s object to be less than or equal to the provided object.
Declared In
AVQuery.h
– whereKey:greaterThan:
Add a constraint to the query that requires a particular key’s object to be greater than the provided object.
- (void)whereKey:(NSString *)key greaterThan:(id)object
Parameters
key |
The key to be constrained. |
---|---|
object |
The object that must be equalled. |
Discussion
Add a constraint to the query that requires a particular key’s object to be greater than the provided object.
Declared In
AVQuery.h
– whereKey:greaterThanOrEqualTo:
Add a constraint to the query that requires a particular key’s object to be greater than or equal to the provided object.
- (void)whereKey:(NSString *)key greaterThanOrEqualTo:(id)object
Parameters
key |
The key to be constrained. |
---|---|
object |
The object that must be equalled. |
Discussion
Add a constraint to the query that requires a particular key’s object to be greater than or equal to the provided object.
Declared In
AVQuery.h
– whereKey:notEqualTo:
Add a constraint to the query that requires a particular key’s object to be not equal to the provided object.
- (void)whereKey:(NSString *)key notEqualTo:(id)object
Parameters
key |
The key to be constrained. |
---|---|
object |
The object that must not be equalled. |
Discussion
Add a constraint to the query that requires a particular key’s object to be not equal to the provided object.
Declared In
AVQuery.h
– whereKey:containedIn:
Add a constraint to the query that requires a particular key’s object to be contained in the provided array.
- (void)whereKey:(NSString *)key containedIn:(NSArray *)array
Parameters
key |
The key to be constrained. |
---|---|
array |
The possible values for the key’s object. |
Discussion
Add a constraint to the query that requires a particular key’s object to be contained in the provided array.
Declared In
AVQuery.h
– whereKey:notContainedIn:
Add a constraint to the query that requires a particular key’s object not be contained in the provided array.
- (void)whereKey:(NSString *)key notContainedIn:(NSArray *)array
Parameters
key |
The key to be constrained. |
---|---|
array |
The list of values the key’s object should not be. |
Discussion
Add a constraint to the query that requires a particular key’s object not be contained in the provided array.
Declared In
AVQuery.h
– whereKey:containsAllObjectsInArray:
Add a constraint to the query that requires a particular key’s array contains every element of the provided array.
- (void)whereKey:(NSString *)key containsAllObjectsInArray:(NSArray *)array
Parameters
key |
The key to be constrained. |
---|---|
array |
The array of values to search for. |
Discussion
Add a constraint to the query that requires a particular key’s array contains every element of the provided array.
Declared In
AVQuery.h
Adding Location Constraints
– whereKey:nearGeoPoint:
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point. Distance is calculated based on angular distance on a sphere. Results will be sorted by distance from reference point.
- (void)whereKey:(NSString *)key nearGeoPoint:(AVGeoPoint *)geoPoint
Parameters
key |
The key to be constrained. |
---|---|
geoPoint |
The reference point. A AVGeoPoint. |
Discussion
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point. Distance is calculated based on angular distance on a sphere. Results will be sorted by distance from reference point.
Declared In
AVQuery.h
– whereKey:nearGeoPoint:withinMiles:
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the maximum distance specified (in miles). Distance is calculated based on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.
- (void)whereKey:(NSString *)key nearGeoPoint:(AVGeoPoint *)geoPoint withinMiles:(double)maxDistance
Parameters
key |
The key to be constrained. |
---|---|
geoPoint |
The reference point. A AVGeoPoint. |
maxDistance |
Maximum distance in miles. |
Discussion
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the maximum distance specified (in miles). Distance is calculated based on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.
Declared In
AVQuery.h
– whereKey:nearGeoPoint:withinKilometers:
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the maximum distance specified (in kilometers). Distance is calculated based on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.
- (void)whereKey:(NSString *)key nearGeoPoint:(AVGeoPoint *)geoPoint withinKilometers:(double)maxDistance
Parameters
key |
The key to be constrained. |
---|---|
geoPoint |
The reference point. A AVGeoPoint. |
maxDistance |
Maximum distance in kilometers. |
Discussion
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the maximum distance specified (in kilometers). Distance is calculated based on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.
Declared In
AVQuery.h
– whereKey:nearGeoPoint:withinRadians:
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the maximum distance specified (in radians). Distance is calculated based on angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.
- (void)whereKey:(NSString *)key nearGeoPoint:(AVGeoPoint *)geoPoint withinRadians:(double)maxDistance
Parameters
key |
The key to be constrained. |
---|---|
geoPoint |
The reference point. A AVGeoPoint. |
maxDistance |
Maximum distance in radians. |
Discussion
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the maximum distance specified (in radians). Distance is calculated based on angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.
Declared In
AVQuery.h
– whereKey:nearGeoPoint:maxDistance:maxDistanceUnit:minDistance:minDistanceUnit:
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the maximum and minimum distance. Distance is calculated based on angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.
- (void)whereKey:(NSString *)key nearGeoPoint:(AVGeoPoint *)geoPoint maxDistance:(double)maxDistance maxDistanceUnit:(AVQueryDistanceUnit)maxDistanceUnit minDistance:(double)minDistance minDistanceUnit:(AVQueryDistanceUnit)minDistanceUnit
Parameters
key |
The key to be constrained. |
---|---|
geoPoint |
The reference point, a AVGeoPoint. |
maxDistance |
Maximum distance value. If negative (like -1), the maximum constraint will be ignored. |
maxDistanceUnit |
Maximum distance unit. |
minDistance |
Minimum distance value. If negative (like -1), the minimum constraint will be ignored. |
minDistanceUnit |
Minimum distance unit. |
Discussion
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the maximum and minimum distance. Distance is calculated based on angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.
Declared In
AVQuery.h
– whereKey:nearGeoPoint:minDistance:minDistanceUnit:
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the minimum distance. Distance is calculated based on angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.
- (void)whereKey:(NSString *)key nearGeoPoint:(AVGeoPoint *)geoPoint minDistance:(double)minDistance minDistanceUnit:(AVQueryDistanceUnit)minDistanceUnit
Parameters
key |
The key to be constrained. |
---|---|
geoPoint |
The reference point, a AVGeoPoint. |
minDistance |
Minimum distance value. If negative (like -1), the minimum constraint will be ignored. |
minDistanceUnit |
Minimum distance unit. |
Discussion
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be near a reference point and within the minimum distance. Distance is calculated based on angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.
Declared In
AVQuery.h
– whereKey:withinGeoBoxFromSouthwest:toNortheast:
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be contained within a given rectangular geographic bounding box.
- (void)whereKey:(NSString *)key withinGeoBoxFromSouthwest:(AVGeoPoint *)southwest toNortheast:(AVGeoPoint *)northeast
Parameters
key |
The key to be constrained. |
---|---|
southwest |
The lower-left inclusive corner of the box. |
northeast |
The upper-right inclusive corner of the box. |
Discussion
Add a constraint to the query that requires a particular key’s coordinates (specified via AVGeoPoint) be contained within a given rectangular geographic bounding box.
Declared In
AVQuery.h
Adding String Constraints
– whereKey:matchesRegex:
Add a regular expression constraint for finding string values that match the provided regular expression. This may be slow for large datasets.
- (void)whereKey:(NSString *)key matchesRegex:(NSString *)regex
Parameters
key |
The key that the string to match is stored in. |
---|---|
regex |
The regular expression pattern to match. |
Discussion
Add a regular expression constraint for finding string values that match the provided regular expression. This may be slow for large datasets.
Declared In
AVQuery.h
– whereKey:matchesRegex:modifiers:
Add a regular expression constraint for finding string values that match the provided regular expression. This may be slow for large datasets.
- (void)whereKey:(NSString *)key matchesRegex:(NSString *)regex modifiers:(nullable NSString *)modifiers
Parameters
key |
The key that the string to match is stored in. |
---|---|
regex |
The regular expression pattern to match. |
modifiers |
Any of the following supported PCRE modifiers: |
Discussion
Add a regular expression constraint for finding string values that match the provided regular expression. This may be slow for large datasets.
Declared In
AVQuery.h
– whereKey:containsString:
Add a constraint for finding string values that contain a provided substring. This will be slow for large datasets.
- (void)whereKey:(NSString *)key containsString:(NSString *)substring
Parameters
key |
The key that the string to match is stored in. |
---|---|
substring |
The substring that the value must contain. |
Discussion
Add a constraint for finding string values that contain a provided substring. This will be slow for large datasets.
Declared In
AVQuery.h
– whereKey:hasPrefix:
Add a constraint for finding string values that start with a provided prefix. This will use smart indexing, so it will be fast for large datasets.
- (void)whereKey:(NSString *)key hasPrefix:(NSString *)prefix
Parameters
key |
The key that the string to match is stored in. |
---|---|
prefix |
The substring that the value must start with. |
Discussion
Add a constraint for finding string values that start with a provided prefix. This will use smart indexing, so it will be fast for large datasets.
Declared In
AVQuery.h
– whereKey:hasSuffix:
Add a constraint for finding string values that end with a provided suffix. This will be slow for large datasets.
- (void)whereKey:(NSString *)key hasSuffix:(NSString *)suffix
Parameters
key |
The key that the string to match is stored in. |
---|---|
suffix |
The substring that the value must end with. |
Discussion
Add a constraint for finding string values that end with a provided suffix. This will be slow for large datasets.
Declared In
AVQuery.h
Adding Subqueries
+ orQueryWithSubqueries:
Returns a AVQuery that is the or of the passed in AVQuerys.
+ (AVQuery *)orQueryWithSubqueries:(NSArray *)queries
Parameters
queries |
The list of queries to or together. |
---|
Return Value
a AVQuery that is the or of the passed in AVQuerys.
Discussion
Returns a AVQuery that is the or of the passed in AVQuerys.
Declared In
AVQuery.h
+ andQueryWithSubqueries:
Returns a AVQuery that is the AND of the passed in AVQuerys.
+ (AVQuery *)andQueryWithSubqueries:(NSArray *)queries
Parameters
queries |
The list of queries to AND together. |
---|
Return Value
a AVQuery that is the AND of the passed in AVQuerys.
Discussion
Returns a AVQuery that is the AND of the passed in AVQuerys.
Declared In
AVQuery.h
– whereKey:matchesKey:inQuery:
Adds a constraint that requires that a key’s value matches a value in another key in objects returned by a sub query.
- (void)whereKey:(NSString *)key matchesKey:(NSString *)otherKey inQuery:(AVQuery *)query
Parameters
key |
The key that the value is stored |
---|---|
otherKey |
The key in objects in the returned by the sub query whose value should match |
query |
The query to run. |
Discussion
Adds a constraint that requires that a key’s value matches a value in another key in objects returned by a sub query.
Declared In
AVQuery.h
– whereKey:doesNotMatchKey:inQuery:
Adds a constraint that requires that a key’s value NOT match a value in another key in objects returned by a sub query.
- (void)whereKey:(NSString *)key doesNotMatchKey:(NSString *)otherKey inQuery:(AVQuery *)query
Parameters
key |
The key that the value is stored |
---|---|
otherKey |
The key in objects in the returned by the sub query whose value should match |
query |
The query to run. |
Discussion
Adds a constraint that requires that a key’s value NOT match a value in another key in objects returned by a sub query.
Declared In
AVQuery.h
– whereKey:matchesQuery:
Add a constraint that requires that a key’s value matches a AVQuery constraint. This only works where the key’s values are AVObjects or arrays of AVObjects.
- (void)whereKey:(NSString *)key matchesQuery:(AVQuery *)query
Parameters
key |
The key that the value is stored in |
---|---|
query |
The query the value should match |
Discussion
Add a constraint that requires that a key’s value matches a AVQuery constraint. This only works where the key’s values are AVObjects or arrays of AVObjects.
Declared In
AVQuery.h
– whereKey:doesNotMatchQuery:
Add a constraint that requires that a key’s value to not match a AVQuery constraint. This only works where the key’s values are AVObjects or arrays of AVObjects.
- (void)whereKey:(NSString *)key doesNotMatchQuery:(AVQuery *)query
Parameters
key |
The key that the value is stored in |
---|---|
query |
The query the value should not match |
Discussion
Add a constraint that requires that a key’s value to not match a AVQuery constraint. This only works where the key’s values are AVObjects or arrays of AVObjects.
Declared In
AVQuery.h
– whereKey:sizeEqualTo:
Matches any array with the number of elements specified by count
- (void)whereKey:(NSString *)key sizeEqualTo:(NSUInteger)count
Parameters
key |
The key that the value is stored in, value should be kind of array |
---|---|
count |
the array size |
Discussion
Matches any array with the number of elements specified by count
Declared In
AVQuery.h
Sorting
– orderByAscending:
Sort the results in ascending order with the given key.
- (void)orderByAscending:(NSString *)key
Parameters
key |
The key to order by. |
---|
Discussion
Sort the results in ascending order with the given key.
Declared In
AVQuery.h
– addAscendingOrder:
Also sort in ascending order by the given key. The previous keys provided will precedence over this key.
- (void)addAscendingOrder:(NSString *)key
Parameters
key |
The key to order bye |
---|
Discussion
Also sort in ascending order by the given key. The previous keys provided will precedence over this key.
Declared In
AVQuery.h
– orderByDescending:
Sort the results in descending order with the given key.
- (void)orderByDescending:(NSString *)key
Parameters
key |
The key to order by. |
---|
Discussion
Sort the results in descending order with the given key.
Declared In
AVQuery.h
– addDescendingOrder:
Also sort in descending order by the given key. The previous keys provided will precedence over this key.
- (void)addDescendingOrder:(NSString *)key
Parameters
key |
The key to order bye |
---|
Discussion
Also sort in descending order by the given key. The previous keys provided will precedence over this key.
Declared In
AVQuery.h
– orderBySortDescriptor:
Sort the results in descending order with the given descriptor.
- (void)orderBySortDescriptor:(NSSortDescriptor *)sortDescriptor
Parameters
sortDescriptor |
The NSSortDescriptor to order by. |
---|
Discussion
Sort the results in descending order with the given descriptor.
Declared In
AVQuery.h
– orderBySortDescriptors:
Sort the results in descending order with the given descriptors.
- (void)orderBySortDescriptors:(NSArray *)sortDescriptors
Parameters
sortDescriptors |
An NSArray of NSSortDescriptor instances to order by. |
---|
Discussion
Sort the results in descending order with the given descriptors.
Declared In
AVQuery.h
Getting Objects by ID
+ getObjectOfClass:objectId:
Returns a AVObject with a given class and id.
+ (nullable AVObject *)getObjectOfClass:(NSString *)objectClass objectId:(NSString *)objectId
Parameters
objectClass |
The class name for the object that is being requested. |
---|---|
objectId |
The id of the object that is being requested. |
Return Value
The AVObject if found. Returns nil if the object isn’t found, or if there was an error.
Discussion
Returns a AVObject with a given class and id.
Declared In
AVQuery.h
+ getObjectOfClass:objectId:error:
Returns a AVObject with a given class and id and sets an error if necessary.
+ (nullable AVObject *)getObjectOfClass:(NSString *)objectClass objectId:(NSString *)objectId error:(NSError **)error
Parameters
objectClass |
The class name for the object that is being requested. |
---|---|
objectId |
The id of the object that is being requested. |
error |
Pointer to an NSError that will be set if necessary. |
Return Value
The AVObject if found. Returns nil if the object isn’t found, or if there was an error.
Discussion
Returns a AVObject with a given class and id and sets an error if necessary.
Declared In
AVQuery.h
– getObjectWithId:
– getObjectWithId:error:
Returns a AVObject with the given id and sets an error if necessary.
- (nullable AVObject *)getObjectWithId:(NSString *)objectId error:(NSError **)error
Parameters
objectId |
The id of the object that is being requested. |
---|---|
error |
Pointer to an NSError that will be set if necessary. |
Return Value
The AVObject if found. Returns nil if the object isn’t found, or if there was an error.
Discussion
Returns a AVObject with the given id and sets an error if necessary.
This mutates the AVQuery
Declared In
AVQuery.h
– getObjectInBackgroundWithId:block:
Gets a AVObject asynchronously and calls the given block with the result.
- (void)getObjectInBackgroundWithId:(NSString *)objectId block:(AVObjectResultBlock)block
Parameters
objectId |
The id of the object being requested. |
---|---|
block |
The block to execute. The block should have the following argument signature: (NSArray object, NSError error) |
Discussion
Gets a AVObject asynchronously and calls the given block with the result.
This mutates the AVQuery
Declared In
AVQuery.h
– getObjectInBackgroundWithId:target:selector:
Gets a AVObject asynchronously.
- (void)getObjectInBackgroundWithId:(NSString *)objectId target:(id)target selector:(SEL)selector
Parameters
objectId |
The id of the object being requested. |
---|---|
target |
The target for the callback selector. |
selector |
The selector for the callback. It should have the following signature: (void)callbackWithResult:(AVObject )result error:(NSError )error. result will be nil if error is set and vice versa. |
Declared In
AVQuery.h
Getting User Objects
+ getUserObjectWithId:
Returns a AVUser with a given id.
+ (nullable AVUser *)getUserObjectWithId:(NSString *)objectId
Parameters
objectId |
The id of the object that is being requested. |
---|
Return Value
The AVUser if found. Returns nil if the object isn’t found, or if there was an error.
Discussion
Returns a AVUser with a given id.
Declared In
AVQuery.h
+ getUserObjectWithId:error:
Returns a AVUser with a given class and id and sets an error if necessary.
+ (nullable AVUser *)getUserObjectWithId:(NSString *)objectId error:(NSError **)error
Parameters
objectId |
The id of the object that is being requested. |
---|---|
error |
Pointer to an NSError that will be set if necessary. |
Return Value
The AVUser if found. Returns nil if the object isn’t found, or if there was an error.
Discussion
Returns a AVUser with a given class and id and sets an error if necessary.
Declared In
AVQuery.h
+ queryForUser
Deprecated. Please use [AVUser query] instead.
+ (instancetype)queryForUser
Discussion
Deprecated. Please use [AVUser query] instead.
Declared In
AVQuery.h
Getting all Matches for a Query
– findObjects
Finds objects based on the constructed query.
- (nullable NSArray *)findObjects
Return Value
an array of AVObjects that were found.
Discussion
Finds objects based on the constructed query.
Declared In
AVQuery.h
– findObjects:
Finds objects based on the constructed query and sets an error if there was one.
- (nullable NSArray *)findObjects:(NSError **)error
Parameters
error |
Pointer to an NSError that will be set if necessary. |
---|
Return Value
an array of AVObjects that were found.
Discussion
Finds objects based on the constructed query and sets an error if there was one.
Declared In
AVQuery.h
– findObjectsAndThrowsWithError:
An alias of [AVQuery findObjects:]
methods that supports Swift exception.
@seealso [AVQuery findObjects:]
- (nullable NSArray *)findObjectsAndThrowsWithError:(NSError **)error
Discussion
An alias of [AVQuery findObjects:]
methods that supports Swift exception.
@seealso [AVQuery findObjects:]
Declared In
AVQuery.h
– findObjectsInBackgroundWithBlock:
Finds objects asynchronously and calls the given block with the results.
- (void)findObjectsInBackgroundWithBlock:(AVArrayResultBlock)block
Parameters
block |
The block to execute. The block should have the following argument signature:(NSArray objects, NSError error) |
---|
Discussion
Finds objects asynchronously and calls the given block with the results.
Declared In
AVQuery.h
– findObjectsInBackgroundWithTarget:selector:
Finds objects asynchronously and calls the given callback with the results.
- (void)findObjectsInBackgroundWithTarget:(id)target selector:(SEL)selector
Parameters
target |
The object to call the selector on. |
---|---|
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(NSArray )result error:(NSError )error. result will be nil if error is set and vice versa. |
Discussion
Finds objects asynchronously and calls the given callback with the results.
Declared In
AVQuery.h
– deleteAllInBackgroundWithBlock:
Remove objects asynchronously and calls the given block with the results.
- (void)deleteAllInBackgroundWithBlock:(AVBooleanResultBlock)block
Parameters
block |
The block to execute. The block should have the following argument signature:(NSArray objects, NSError error) |
---|
Discussion
Remove objects asynchronously and calls the given block with the results.
Declared In
AVQuery.h
Getting the First Match in a Query
– getFirstObject
Gets an object based on the constructed query.
- (nullable AVObject *)getFirstObject
Return Value
a AVObject, or nil if none was found.
Discussion
Gets an object based on the constructed query.
This mutates the AVQuery.
Declared In
AVQuery.h
– getFirstObject:
Gets an object based on the constructed query and sets an error if any occurred.
- (nullable AVObject *)getFirstObject:(NSError **)error
Parameters
error |
Pointer to an NSError that will be set if necessary. |
---|
Return Value
a AVObject, or nil if none was found.
Discussion
Gets an object based on the constructed query and sets an error if any occurred.
This mutates the AVQuery.
Declared In
AVQuery.h
– getFirstObjectAndThrowsWithError:
An alias of [AVQuery getFirstObject:]
methods that supports Swift exception.
@seealso [AVQuery getFirstObject:]
- (nullable AVObject *)getFirstObjectAndThrowsWithError:(NSError **)error
Discussion
An alias of [AVQuery getFirstObject:]
methods that supports Swift exception.
@seealso [AVQuery getFirstObject:]
Declared In
AVQuery.h
– getFirstObjectInBackgroundWithBlock:
Gets an object asynchronously and calls the given block with the result.
- (void)getFirstObjectInBackgroundWithBlock:(AVObjectResultBlock)block
Parameters
block |
The block to execute. The block should have the following argument signature:(AVObject object, NSError error) result will be nil if error is set OR no object was found matching the query. error will be nil if result is set OR if the query succeeded, but found no results. |
---|
Discussion
Gets an object asynchronously and calls the given block with the result.
This mutates the AVQuery.
Declared In
AVQuery.h
– getFirstObjectInBackgroundWithTarget:selector:
Gets an object asynchronously and calls the given callback with the results.
- (void)getFirstObjectInBackgroundWithTarget:(id)target selector:(SEL)selector
Parameters
target |
The object to call the selector on. |
---|---|
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(AVObject )result error:(NSError )error. result will be nil if error is set OR no object was found matching the query. error will be nil if result is set OR if the query succeeded, but found no results. |
Discussion
Gets an object asynchronously and calls the given callback with the results.
This mutates the AVQuery.
Declared In
AVQuery.h
Counting the Matches in a Query
– countObjects
Counts objects based on the constructed query.
- (NSInteger)countObjects
Return Value
the number of AVObjects that match the query, or -1 if there is an error.
Discussion
Counts objects based on the constructed query.
Declared In
AVQuery.h
– countObjects:
Counts objects based on the constructed query and sets an error if there was one.
- (NSInteger)countObjects:(NSError **)error
Parameters
error |
Pointer to an NSError that will be set if necessary. |
---|
Return Value
the number of AVObjects that match the query, or -1 if there is an error.
Discussion
Counts objects based on the constructed query and sets an error if there was one.
Declared In
AVQuery.h
– countObjectsAndThrowsWithError:
An alias of [AVQuery countObjects:]
methods that supports Swift exception.
@seealso [AVQuery countObjects:]
- (NSInteger)countObjectsAndThrowsWithError:(NSError **)error
Discussion
An alias of [AVQuery countObjects:]
methods that supports Swift exception.
@seealso [AVQuery countObjects:]
Declared In
AVQuery.h
– countObjectsInBackgroundWithBlock:
Counts objects asynchronously and calls the given block with the counts.
- (void)countObjectsInBackgroundWithBlock:(AVIntegerResultBlock)block
Parameters
block |
The block to execute. The block should have the following argument signature: (int count, NSError *error) |
---|
Discussion
Counts objects asynchronously and calls the given block with the counts.
Declared In
AVQuery.h
– countObjectsInBackgroundWithTarget:selector:
Counts objects asynchronously and calls the given callback with the count.
- (void)countObjectsInBackgroundWithTarget:(id)target selector:(SEL)selector
Parameters
target |
The object to call the selector on. |
---|---|
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(NSNumber )result error:(NSError )error. |
Discussion
Counts objects asynchronously and calls the given callback with the count.
Declared In
AVQuery.h
Cancelling a Query
– cancel
Cancels the current network request (if any). Ensures that callbacks won’t be called.
- (void)cancel
Discussion
Cancels the current network request (if any). Ensures that callbacks won’t be called.
Declared In
AVQuery.h
Paginating Results
limit
A limit on the number of objects to return. Note: If you are calling findObject with limit=1, you may find it easier to use getFirst instead.
@property (nonatomic, assign) NSInteger limit
Discussion
A limit on the number of objects to return. Note: If you are calling findObject with limit=1, you may find it easier to use getFirst instead.
Declared In
AVQuery.h
skip
The number of objects to skip before returning any.
@property (nonatomic, assign) NSInteger skip
Discussion
The number of objects to skip before returning any.
Declared In
AVQuery.h
includeACL
Include ACL for object.
@property (nonatomic, assign) BOOL includeACL
Discussion
Include ACL for object.
Declared In
AVQuery.h
Controlling Caching Behavior
cachePolicy
The cache policy to use for requests.
@property (readwrite, assign) AVCachePolicy cachePolicy
Discussion
The cache policy to use for requests.
Declared In
AVQuery.h
– hasCachedResult
Returns whether there is a cached result for this query.
- (BOOL)hasCachedResult
Return Value
YES if there is a cached result for this query, and NO otherwise.
Discussion
Returns whether there is a cached result for this query.
Declared In
AVQuery.h
– clearCachedResult
Clears the cached result for this query. If there is no cached result, this is a noop.
- (void)clearCachedResult
Discussion
Clears the cached result for this query. If there is no cached result, this is a noop.
Declared In
AVQuery.h
+ clearAllCachedResults
Clears the cached results for all queries.
+ (void)clearAllCachedResults
Discussion
Clears the cached results for all queries.
Declared In
AVQuery.h
Advanced Settings
trace
Whether or not performance tracing should be done on the query. This should not be set in most cases.
@property (nonatomic, assign) BOOL trace
Discussion
Whether or not performance tracing should be done on the query. This should not be set in most cases.
Declared In
AVQuery.h