Inherits from NSObject
Declared in KiiClause.h

Overview

Build a query using one or more KiiClause methods

Class Methods

and:

Use [KiiClause andClauses:] instead (Deprecated: Use [KiiClause andClauses:] instead)

+ (KiiClause *)and:(KiiClause *)clause, ...

Declared In

KiiClause.h

andClauses:

Create a KiiClause with the AND operator concatenating multiple KiiClause objects

+ (nullable KiiClause *)andClauses:(NSArray *)clauses

Parameters

clauses

An array KiiClause objects to concatenate

Return Value

KiiClause instance with concatenated AND operator,or nil if array contains any non KiiClause instance

Discussion

Create a KiiClause with the AND operator concatenating multiple KiiClause objects

Declared In

KiiClause.h

equals:value:

Create an expression of the form key = value

+ (KiiClause *)equals:(NSString *)key value:(id)value

Parameters

key

The key to compare

value

The value to compare

Discussion

Create an expression of the form key = value

Declared In

KiiClause.h

geoBox:northEast:southWest:

Create a clause of geo box. This clause inquires objects in the specified rectangle. Rectangle would be placed parallel to the equator with specified coordinates of the corner. Throws NSInvalidArgumentException when key is nil or empty, northEast or southWest is nil.

+ (KiiClause *)geoBox:(NSString *)key northEast:(KiiGeoPoint *)ne southWest:(KiiGeoPoint *)sw

Parameters

key

name of the key to inquire, which holds geo point.

ne

north-east corner of the rectangle.

sw

south-west corner of the rectangle.

Return Value

KiiClause instance.

Discussion

Create a clause of geo box. This clause inquires objects in the specified rectangle. Rectangle would be placed parallel to the equator with specified coordinates of the corner. Throws NSInvalidArgumentException when key is nil or empty, northEast or southWest is nil.

Declared In

KiiClause.h

geoDistance:center:radius:putDistanceInto:

Create a clause of geo distance. This clause inquires objects in the specified circle. Throws NSInvalidArgumentException when key is nil or empty, centor is nil or radius is out of range

+ (KiiClause *)geoDistance:(NSString *)key center:(KiiGeoPoint *)center radius:(double)radius putDistanceInto:(nullable NSString *)calculatedDistance

Parameters

key

name of the key to inquire, which holds geo point.

center

geo point which specify center of the circle.

radius

of the circle. unit is meter. value should be in range of ]0, 20000000]

calculatedDistance

used for retrieve distance from the center from the query result. If the specified value is nil, query result will not contain the distance. Note: You can get the results in ascending order of distances from center. To do so, build the orderBy field by “_calculated.{specified value of calculatedDistance}” and pass it in [KiiQuery sortByAsc:] Note that, descending order of distances is not supported. The unit of distance is meter.

NSString* calculatedDistance = @"distanceFromCurrentLoc";
KiiGeoPoint* currentLoc = ..; // current location
KiiClause* geoDist = [KiiClause geoDistance:@"location" center:currentLoc radius:7 putDistanceInto:calculatedDistance];
KiiQuery *query = [KiiQuery queryWithClause:geoDist];
// Sort by distances by ascending order.(Optional, use only if you intend to retrieve the distances in a ascending order).
NSString* orderByKey = [@"_calculated." stringByAppendingString:calculatedDistance];
[query sortByAsc:orderByKey];
NSMutableArray *allResults = [NSMutableArray array];
KiiQuery *nextQuery;
KiiBucket *bucket = [Kii bucketWithName:@"MyBucket"];
KiiError *error = nil;
NSArray *results = [bucket executeQuerySynchronous:query withError:&error andNext:&nextQuery];

// add the results to our main array
[allResults addObjectsFromArray:results];
KiiObject* object = [allResults objectAtIndex:0];
NSDictionary* cal = [object getObjectForKey:@"_calculated"];
NSNumber* distanceInMeter = [cal objectForKey:calculatedDistance];

Return Value

KiiClause instance.

Discussion

Create a clause of geo distance. This clause inquires objects in the specified circle. Throws NSInvalidArgumentException when key is nil or empty, centor is nil or radius is out of range

Declared In

KiiClause.h

greaterThan:value:

Create an expression of the form key > value

+ (KiiClause *)greaterThan:(NSString *)key value:(id)value

Parameters

key

The key to compare

value

The value to compare

Discussion

Create an expression of the form key > value

Declared In

KiiClause.h

greaterThanOrEqual:value:

Create an expression of the form key >= value

+ (KiiClause *)greaterThanOrEqual:(NSString *)key value:(id)value

Parameters

key

The key to compare

value

The value to compare

Discussion

Create an expression of the form key >= value

Declared In

KiiClause.h

hasField:andType:

Create an expression to returns all entities that have a specified field and type.

+ (KiiClause *)hasField:(NSString *)key andType:(KiiFieldType)fieldType

Parameters

key

name of the specified field.

fieldType

The type of the content of the field.

Return Value

KiiClause instance that construct hasField query.

Discussion

Create an expression to returns all entities that have a specified field and type.

Declared In

KiiClause.h

in:value:

Create an expression of the form key in [ values[0], values[1], … ]

+ (KiiClause *)in:(NSString *)key value:(NSArray *)values

Parameters

key

The key to compare

values

The values to compare

Discussion

Create an expression of the form key in [ values[0], values[1], … ]

Declared In

KiiClause.h

lessThan:value:

Create an expression of the form key < value

+ (KiiClause *)lessThan:(NSString *)key value:(id)value

Parameters

key

The key to compare

value

The value to compare

Discussion

Create an expression of the form key < value

Declared In

KiiClause.h

lessThanOrEqual:value:

Create an expression of the form key <= value

+ (KiiClause *)lessThanOrEqual:(NSString *)key value:(id)value

Parameters

key

The key to compare

value

The value to compare

Discussion

Create an expression of the form key <= value

Declared In

KiiClause.h

notClause:

Create a KiiClause with the NOT operator concatenating multiple KiiClause objects

+ (KiiClause *)notClause:(KiiClause *)clause

Parameters

clause

to be concatenated with NOT operator.

Return Value

KiiClause instance with concatenated NO operator

Discussion

Create a KiiClause with the NOT operator concatenating multiple KiiClause objects

Note: Query performance will be worse as the number of objects in bucket increases, so we recommend you avoid the NOT clause if possible.

Declared In

KiiClause.h

notEquals:value:

Create an expression of the form key != value

+ (KiiClause *)notEquals:(NSString *)key value:(id)value

Parameters

key

The key to compare

value

The value to compare

Discussion

Create an expression of the form key != value

Declared In

KiiClause.h

or:

Use [KiiClause orClauses:] instead. (Deprecated: Use [KiiClause orClauses:] instead.)

+ (KiiClause *)or:(KiiClause *)clause, ...

Declared In

KiiClause.h

orClauses:

Create a KiiClause with the OR operator concatenating multiple KiiClause objects

+ (nullable KiiClause *)orClauses:(NSArray *)clauses

Parameters

clauses

An array KiiClause objects to concatenate

Return Value

KiiClause instance with concatenated OR operator,or nil if array contains any non KiiClause instance

Discussion

Create a KiiClause with the OR operator concatenating multiple KiiClause objects

Note: Query performance will be worse as the number of objects in bucket increases, so we recommend you avoid the OR clause if possible.

Declared In

KiiClause.h

startsWith:value:

Create an expression of the form key STARTS WITH value

+ (KiiClause *)startsWith:(NSString *)key value:(NSString *)value

Parameters

key

The key to compare

value

The value to check for

Discussion

Create an expression of the form key STARTS WITH value

Declared In

KiiClause.h