DatabaseKit  0.5
DBModel Class Reference

#import <DBModel.h>

Inheritance diagram for DBModel:
[legend]
Collaboration diagram for DBModel:
[legend]

Instance Methods

(DBWriteQuery *) - saveQueryForKey:
 
(DBQuery *) - query
 

Class Methods

(NSSet *) + savedKeys
 
(NSSet *) + excludedKeys
 
(NSArray *) + indices
 
(NSArray *) + constraintsForKey:
 
(NSString *) + tableName
 

Properties

DBdatabase
 
NSUUID * UUID
 
BOOL saved
 
BOOL hasChanges
 

Detailed Description

An abstract base class for objects that should model a table.
Any keys not excluded by +excludedKeys will be saved to the table if a column with the same name is present.

Definition at line 12 of file DBModel.h.

Method Documentation

+ (NSArray *) constraintsForKey: (NSString *)  key

Returns an array of constraints for a key To specify constraints for a key you should define a method with a name like: -constraintsForMyKey

Definition at line 97 of file DBModel.m.

References key.

+ (NSSet *) excludedKeys

Returns the set of keys that should NOT be saved to a database (Used by +savedKeys)

Definition at line 82 of file DBModel.m.

Referenced by savedKeys.

+ (NSArray *) indices

Returns an array of DBIndices for the model

Definition at line 92 of file DBModel.m.

- (DBQuery *) query

Creates a query with a WHERE clause specifying the record

Definition at line 287 of file DBModel.m.

References tableName.

+ (NSSet *) savedKeys

Returns the set of keys that should be saved to a database

Definition at line 51 of file DBModel.m.

References DBIteratePropertiesForClass(), excludedKeys, key, and savedKeys.

Referenced by savedKeys.

- (DBWriteQuery *) saveQueryForKey: (NSString *)  key

Returns a query to use to save a given key to the database. To override query generation for a key you should implement a method named like -saveQueryForMyKey Remember to handle both the insert and update cases.

Definition at line 222 of file DBModel.m.

References DBAttributesForProperty(), and key.

+ (NSString *) tableName

Returns the table name of the record based on the class name by converting it to lowercase, pluralizing it and removing the class prefix if one is set.

Definition at line 294 of file DBModel.m.

Referenced by query.

Property Documentation

- (DB *) database
readatomicstrong

Definition at line 13 of file DBModel.h.

- (BOOL) hasChanges
readatomicassign

Definition at line 16 of file DBModel.h.

- (BOOL) saved
readatomicassign

Definition at line 15 of file DBModel.h.

- (NSUUID*) UUID
readwriteatomiccopy

Definition at line 14 of file DBModel.h.


The documentation for this class was generated from the following files: