RBORMObject Class Reference
Inherits from | RBIntrospectiveObject : NSObject |
---|---|
Declared in | RBORMObject.h |
Overview
Provides a managed ORM (Object relationship management) object for use with SQLite.
- Note: NSDates are automatically serialized and deserialized. Dates are stored on disk in the ISO 8601 format.
+ tableName
Returns the table name to be used. The default implementation returns the name of the Obj-C class.
+ (nonnull NSString *)tableName
Return Value
The name of the table.
Discussion
Returns the table name to be used. The default implementation returns the name of the Obj-C class.
Declared In
RBORMObject.h
+ nullableProperties
A list of the nullable properties for this object.
+ (nullable NSArray<NSString*> *)nullableProperties
Return Value
A list of the properites that are permitted to be null or nil.
Discussion
A list of the nullable properties for this object.
Declared In
RBORMObject.h
+ propertiesToColumnNames
A mapping of property names to database column names when the names differ.
+ (nullable NSDictionary<NSString*,NSString*> *)propertiesToColumnNames
Return Value
A mapping of the property names and their corresponding database column names.
Discussion
A mapping of property names to database column names when the names differ.
Declared In
RBORMObject.h
pk
The primary key assigned to this object by SQLite. Will be set to a value < 1 if the object has not yet been saved.
@property (readonly) NSUInteger pk
Discussion
The primary key assigned to this object by SQLite. Will be set to a value < 1 if the object has not yet been saved.
Declared In
RBORMObject.h
hasPrimaryKey
Indiciates that a valid primary key value has been set and assigned by SQLite.
@property (nonatomic, readonly) BOOL hasPrimaryKey
Discussion
Indiciates that a valid primary key value has been set and assigned by SQLite.
Declared In
RBORMObject.h
databaseIdentifier
The database identifier this object is associated it. This allows multiple databases to be used at once.
@property (readonly, nonnull) NSString *databaseIdentifier
Discussion
The database identifier this object is associated it. This allows multiple databases to be used at once.
Declared In
RBORMObject.h
– init
Initializes a new RBORMObject
object with the default database identifier (DEFAULT_DATABASE_IDENTIFIER
).
- (nonnull instancetype)init
Return Value
A newly initialized RBORMObject
object.
Discussion
Initializes a new RBORMObject
object with the default database identifier (DEFAULT_DATABASE_IDENTIFIER
).
Declared In
RBORMObject.h
– initWithDatabaseIdentifier:
Initializes a new RBORMObject
object with a specific database identifier.
- (nonnull instancetype)initWithDatabaseIdentifier:(nonnull NSString *)identifier
Parameters
identifier |
The database identifier. |
---|
Return Value
A newly initialized RBORMObject
object.
Discussion
Initializes a new RBORMObject
object with a specific database identifier.
Declared In
RBORMObject.h
– deleteFromDatabase
Deletes this object from the database. Do not override this method.
- (BOOL)deleteFromDatabase
Return Value
Returns YES
if successful.
Discussion
Deletes this object from the database. Do not override this method.
Declared In
RBORMObject.h
– save
Saves this object. An insert or update occurs as needed.
- (BOOL)save
Return Value
Returns YES
if successful.
Discussion
Saves this object. An insert or update occurs as needed.
Declared In
RBORMObject.h
– willInsert
This method is called before inserting.
- (void)willInsert
Discussion
This method is called before inserting.
Declared In
RBORMObject.h
– willUpdate
This method is called before updating.
- (void)willUpdate
Discussion
This method is called before updating.
Declared In
RBORMObject.h
– didInsert:
Called after inserting.
- (void)didInsert:(BOOL)success
Parameters
success |
If |
---|
Discussion
Called after inserting.
Declared In
RBORMObject.h
– didUpdate:
Called after updating.
- (void)didUpdate:(BOOL)success
Parameters
success |
If |
---|
Discussion
Called after updating.
Declared In
RBORMObject.h
– willDeleteFromDatabase
This method is called before deletion.
- (void)willDeleteFromDatabase
Discussion
This method is called before deletion.
Declared In
RBORMObject.h
– didDeleteFromDatabase:
Called after deletion.
- (void)didDeleteFromDatabase:(BOOL)success
Parameters
success |
If |
---|
Discussion
Called after deletion.
Declared In
RBORMObject.h
– willPopulate
This method is called before populating the data in the object instance.
- (void)willPopulate
Discussion
This method is called before populating the data in the object instance.
Declared In
RBORMObject.h
– didPopulate:
Called after population.
- (void)didPopulate:(BOOL)success
Parameters
success |
If |
---|
Discussion
Called after population.
Declared In
RBORMObject.h
+ objectWithDefaultDatabaseIdentifier
Initializes a new RBORMObject
object with the default database identifier (DEFAULT_DATABASE_IDENTIFIER
).
+ (nonnull instancetype)objectWithDefaultDatabaseIdentifier
Return Value
A newly initialized RBORMObject
object.
Discussion
Initializes a new RBORMObject
object with the default database identifier (DEFAULT_DATABASE_IDENTIFIER
).
Declared In
RBORMObject.h
+ objectWithDatabaseIdentifier:
Initializes a new RBORMObject
object with a specific database identifier.
+ (nonnull instancetype)objectWithDatabaseIdentifier:(nonnull NSString *)identifier
Parameters
identifier |
The database identifier. |
---|
Return Value
A newly initialized RBORMObject
object.
Discussion
Initializes a new RBORMObject
object with a specific database identifier.
Declared In
RBORMObject.h
+ populateWithDictionary:databaseIdentifier:
Initializes a new RBORMObject
object using the specified NSDictionary
to populate it with and a database identifier.
+ (nonnull instancetype)populateWithDictionary:(nonnull NSDictionary<NSString*,id> *)record databaseIdentifier:(nonnull NSString *)identifier
Parameters
record |
The data to used for populating. |
---|---|
identifier |
The database identifier. |
Return Value
A newly initialized and populated RBORMObject
object.
Discussion
Initializes a new RBORMObject
object using the specified NSDictionary
to populate it with and a database identifier.
Declared In
RBORMObject.h
+ populateWithResultSet:atRow:databaseIdentifier:
Initializes a new RBORMObject
object from a RBSQLiteResultSet
given the row index and a database identifier.
+ (nonnull instancetype)populateWithResultSet:(nonnull RBSQLiteResultSet *)results atRow:(NSUInteger)row databaseIdentifier:(nonnull NSString *)identifier
Parameters
results |
The |
---|---|
row |
The row index within the |
identifier |
The database identifier. |
Return Value
A newly initialized and populated RBORMObject
object.
Discussion
Initializes a new RBORMObject
object from a RBSQLiteResultSet
given the row index and a database identifier.
Declared In
RBORMObject.h
+ tableExistsWithDatabaseIdentifier:
Determines whether a table exists for this object type in the database who’s identifier is provided.
+ (BOOL)tableExistsWithDatabaseIdentifier:(nonnull NSString *)identifier
Parameters
identifier |
The identifier of the database. |
---|
Return Value
Whether or not the table exists.
Discussion
Determines whether a table exists for this object type in the database who’s identifier is provided.
Declared In
RBORMObject.h
+ createTableIfMissingWithDatabaseIdentifier:
Creates the table for this object type in the database who’s identifier is provided, only if the table is missing.
+ (BOOL)createTableIfMissingWithDatabaseIdentifier:(nonnull NSString *)identifier
Parameters
identifier |
The identifier of the database. |
---|
Return Value
Whether or not the table exists or was created.
Discussion
Creates the table for this object type in the database who’s identifier is provided, only if the table is missing.
Declared In
RBORMObject.h
+ forPk:
Returns the object for the given primary key value.
+ (nullable instancetype)forPk:(NSUInteger)pk
Parameters
pk |
The primary key. |
---|
Return Value
The object matching the primary key or nil
if not found.
Discussion
Returns the object for the given primary key value.
Declared In
RBORMObject.h
+ executeQueryWithString:bindings:databaseIdentifier:
Executes a given SQL query string with the given bindings on the database who’s identifier is given. Expects the results to be of the receiver type, which are then deserialised and an array of objects is returned.
+ (nullable NSArray<__kindofRBORMObject*> *)executeQueryWithString:(nonnull NSString *)queryString bindings:(nullable NSArray *)bindings databaseIdentifier:(nonnull NSString *)databaseIdentifier
Parameters
queryString |
The SQL query string to execute. |
---|---|
bindings |
The corresponding bindings for the SQL query string given. |
databaseIdentifier |
The identifier of the database to query. |
Return Value
An array of the resulting objects of the receiver’s type.
Discussion
Executes a given SQL query string with the given bindings on the database who’s identifier is given. Expects the results to be of the receiver type, which are then deserialised and an array of objects is returned.
Declared In
RBORMObject.h
+ select
Creates a new RBORMQuery
as an SQL ‘SELECT * FROM [table name]’ query.
+ (nonnull RBORMQuery *)select
Return Value
A newly initialized RBORMQuery
object. When executing this query an array of 0 or more typed objects will be returned.
Discussion
Creates a new RBORMQuery
as an SQL ‘SELECT * FROM [table name]’ query.
Declared In
RBORMObject.h
+ delete
Creates a new RBORMQuery
as an SQL ‘DELETE FROM [table name]’ query.
+ (nonnull RBORMQuery *)delete
Return Value
A newly initialized RBORMQuery
object. When executing this query an array containing a single item of type NSNumber
containing a boolean value will be returned.
Discussion
Creates a new RBORMQuery
as an SQL ‘DELETE FROM [table name]’ query.
Declared In
RBORMObject.h
+ countOf:
Creates a new RBORMQuery
as an SQL ‘SELECT COUNT(*)’ query.
+ (nonnull RBORMQuery *)countOf:(nonnull NSString *)propertyName
Parameters
propertyName |
The property corresponding to the database column that should be counted. |
---|
Return Value
A newly initialized RBORMQuery
object. When executing this query an array containing a single item of type NSNumber
will be returned.
Discussion
Creates a new RBORMQuery
as an SQL ‘SELECT COUNT(*)’ query.
Declared In
RBORMObject.h
+ sumOf:
Creates a new RBORMQuery
as an SQL ‘SELECT SUM([property]) FROM [table name]’ query.
+ (nonnull RBORMQuery *)sumOf:(nonnull NSString *)propertyName
Parameters
propertyName |
The property corresponding to the database column that should be summed. |
---|
Return Value
A newly initialized RBORMQuery
object. When executing this query an array containing a single item of type NSNumber
or `[NSNull null] will be returned.
Discussion
Creates a new RBORMQuery
as an SQL ‘SELECT SUM([property]) FROM [table name]’ query.
Declared In
RBORMObject.h
+ averageOf:
Creates a new RBORMQuery
as an SQL ‘SELECT AVG([property]) FROM [table name]’ query.
+ (nonnull RBORMQuery *)averageOf:(nonnull NSString *)propertyName
Parameters
propertyName |
The property corresponding to the database column that should be averaged. |
---|
Return Value
A newly initialized RBORMQuery
object. When executing this query an array containing a single item of type NSNumber
or `[NSNull null] will be returned.
Discussion
Creates a new RBORMQuery
as an SQL ‘SELECT AVG([property]) FROM [table name]’ query.
Declared In
RBORMObject.h
+ minOf:
Creates a new RBORMQuery
as an SQL ‘SELECT MIN([property]) FROM [table name]’ query.
+ (nonnull RBORMQuery *)minOf:(nonnull NSString *)propertyName
Parameters
propertyName |
The property corresponding to the database column that should be averaged. |
---|
Return Value
A newly initialized RBORMQuery
object. When executing this query an array containing a single item of type NSNumber
or `[NSNull null] will be returned.
Discussion
Creates a new RBORMQuery
as an SQL ‘SELECT MIN([property]) FROM [table name]’ query.
Declared In
RBORMObject.h
+ maxOf:
Creates a new RBORMQuery
as an SQL ‘SELECT MAX([property]) FROM [table name]’ query.
+ (nonnull RBORMQuery *)maxOf:(nonnull NSString *)propertyName
Parameters
propertyName |
The property corresponding to the database column that should be averaged. |
---|
Return Value
A newly initialized RBORMQuery
object. When executing this query an array containing a single item of type NSNumber
or `[NSNull null] will be returned.
Discussion
Creates a new RBORMQuery
as an SQL ‘SELECT MAX([property]) FROM [table name]’ query.
Declared In
RBORMObject.h