RBORMQuery Class Reference

Inherits from NSObject
Conforms to NSCopying
Declared in RBORMQuery.h

Overview

Provides a FLUENT API for querying an SQLite database.

+ deleteQueryWithObjectType:withDatabaseIdentifier:

Creates a new DELETE query for the given object type.

+ (nonnull instancetype)deleteQueryWithObjectType:(nonnull Class)objectType withDatabaseIdentifier:(nonnull NSString *)databaseIdentifier

Parameters

objectType

The type of object that will be queried.

databaseIdentifier

The identifier of the database to use.

Return Value

An initialized instance of the RBORMQuery class.

Declared In

RBORMQuery.h

+ selectQueryWithObjectType:withDatabaseIdentifier:

Creates a new SELECT query for the given object type.

+ (nonnull instancetype)selectQueryWithObjectType:(nonnull Class)objectType withDatabaseIdentifier:(nonnull NSString *)databaseIdentifier

Parameters

objectType

The type of object that will be queried.

databaseIdentifier

The identifier of the database to use.

Return Value

An initialized instance of the RBORMQuery class.

Declared In

RBORMQuery.h

+ countQueryWithObjectType:ofProperty:withDatabaseIdentifier:

Creates a new COUNT aggregate query for the given object type.

+ (nonnull instancetype)countQueryWithObjectType:(nonnull Class)objectType ofProperty:(nonnull NSString *)propertyName withDatabaseIdentifier:(nonnull NSString *)databaseIdentifier

Parameters

objectType

The type of object that will be queried.

propertyName

The name of the property who’s values will be aggregated.

databaseIdentifier

The identifier of the database to use.

Return Value

An initialized instance of the RBORMQuery class.

Declared In

RBORMQuery.h

+ sumQueryWithObjectType:ofProperty:withDatabaseIdentifier:

Creates a new SUM aggregate query for the given object type.

+ (nonnull instancetype)sumQueryWithObjectType:(nonnull Class)objectType ofProperty:(nonnull NSString *)propertyName withDatabaseIdentifier:(nonnull NSString *)databaseIdentifier

Parameters

objectType

The type of object that will be queried.

propertyName

The name of the property who’s values will be aggregated.

databaseIdentifier

The identifier of the database to use.

Return Value

An initialized instance of the RBORMQuery class.

Declared In

RBORMQuery.h

+ minQueryWithObjectType:ofProperty:withDatabaseIdentifier:

Creates a new MIN aggregate query for the given object type.

+ (nonnull instancetype)minQueryWithObjectType:(nonnull Class)objectType ofProperty:(nonnull NSString *)propertyName withDatabaseIdentifier:(nonnull NSString *)databaseIdentifier

Parameters

objectType

The type of object that will be queried.

propertyName

The name of the property who’s values will be aggregated.

databaseIdentifier

The identifier of the database to use.

Return Value

An initialized instance of the RBORMQuery class.

Declared In

RBORMQuery.h

+ maxQueryWithObjectType:ofProperty:withDatabaseIdentifier:

Creates a new MAX aggregate query for the given object type.

+ (nonnull instancetype)maxQueryWithObjectType:(nonnull Class)objectType ofProperty:(nonnull NSString *)propertyName withDatabaseIdentifier:(nonnull NSString *)databaseIdentifier

Parameters

objectType

The type of object that will be queried.

propertyName

The name of the property who’s values will be aggregated.

databaseIdentifier

The identifier of the database to use.

Return Value

An initialized instance of the RBORMQuery class.

Declared In

RBORMQuery.h

+ averageQueryWithObjectType:ofProperty:withDatabaseIdentifier:

Creates a new AVERAGE aggregate query for the given object type.

+ (nonnull instancetype)averageQueryWithObjectType:(nonnull Class)objectType ofProperty:(nonnull NSString *)propertyName withDatabaseIdentifier:(nonnull NSString *)databaseIdentifier

Parameters

objectType

The type of object that will be queried.

propertyName

The name of the property who’s values will be aggregated.

databaseIdentifier

The identifier of the database to use.

Return Value

An initialized instance of the RBORMQuery class.

Declared In

RBORMQuery.h

  databaseIdentifer

The identifier of the database that the query will be executed on.

@property (nonatomic, readonly, nonnull) NSString *databaseIdentifer

Declared In

RBORMQuery.h

  objectType

The type of object (and corresponding database table) that the query will be executed on.

@property (nonatomic, readonly, nonnull) Class objectType

Declared In

RBORMQuery.h

  isScalar

Whether or not the query will yield a scalar result type (such as a number).

@property (nonatomic, readonly) BOOL isScalar

Declared In

RBORMQuery.h

  isNonQuery

Whether or not the query will not yield a value result, but rather the number of rows affected or an error message.

@property (nonatomic, readonly) BOOL isNonQuery

Declared In

RBORMQuery.h

  queryString

The SQL query string that represents this query.

@property (nonatomic, readonly, nonnull) NSString *queryString

Declared In

RBORMQuery.h

  bindings

The bindings that are associated respectively with the binding references in queryString.

@property (nonatomic, readonly, nullable) NSArray *bindings

Declared In

RBORMQuery.h

– execute

Compiles and executes the query.

- (nullable NSArray *)execute

Return Value

An NSArray containing a list of any returned results as managed RBORMObject objects. In the case of scalar queries use [array firstObject] to retrieve the scalar value. Will return nil on error.

Declared In

RBORMQuery.h

– where:

The SQL ‘WHERE’ clause.

- (nonnull RBORMQuery *)where:(nonnull NSString *)criteria

Parameters

criteria

A filter indicating which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself).

Return Value

The updated RBORMQuery object.

Declared In

RBORMQuery.h

– where:bindings:

The SQL ‘WHERE’ clause.

- (nonnull RBORMQuery *)where:(nonnull NSString *)criteria bindings:(nullable NSArray *)bindings

Parameters

criteria

A filter indicating which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). The criteria may contain ‘?’ bindings.

bindings

An array of items the provide the values that should correspond to the ‘?’ bidnings specified in the criteria.

Return Value

The updated RBORMQuery object.

Declared In

RBORMQuery.h

– orderBy:

THE SQL ‘ORDER BY’ clause.

- (nonnull RBORMQuery *)orderBy:(nonnull NSString *)orderBy

Parameters

orderBy

The order in which to return the resultant rows formatted as a SQL ORDER BY clause (exclude the ORDER BY itself). Passing null will ommit any ordering

Return Value

The updated RBORMQuery object.

Declared In

RBORMQuery.h

– limit:

The SQL ‘LIMIT’ clause.

- (nonnull RBORMQuery *)limit:(NSUInteger)limit

Parameters

limit

The maximum number of results to return passing 0 returns all matching rows.

Return Value

The updated RBORMQuery object.

Declared In

RBORMQuery.h

– offset:

The SQL ‘OFFSET’ clause.

- (nonnull RBORMQuery *)offset:(NSUInteger)offset

Parameters

offset

The offset from which to returns rows from. A ‘LIMIT’ must be provided for this to take affect, this is ignored otherwise.

Return Value

The updated RBORMQuery object.

Declared In

RBORMQuery.h

– relatedTo:withKeyProperty:

Selects only those items who’s foreign key property name given refers to the object given.

- (nonnull RBORMQuery *)relatedTo:(nonnull RBORMObject *)object withKeyProperty:(nonnull NSString *)propertyName

Parameters

object

The object to filter relations to.

propertyName

The name of the foreign key property on the receiver class.

Return Value

The updated RBORMQuery object.

Declared In

RBORMQuery.h

– forDatabaseIdentifier:

The database identifier for this query. Set to DEFAULT_DATABASE_IDENTIFIER by default.

- (nonnull RBORMQuery *)forDatabaseIdentifier:(nonnull NSString *)identifier

Parameters

identifier

A database identifier indicating which specific database this query should be run on.

Return Value

The updated RBORMQuery object.

Declared In

RBORMQuery.h