OOCModel
@property (readonly) NSString* id
Unique identifier of the instance. If id
does not exist when the object is saved, an autoincrement numeric value is assigned.
+ (OOCSet) find:(NSDictionary)dict
Convenience method for Ohmoc
.-find:model:
.
+ (instancetype) with:(NSString*)property is:(id)value
Convenience method for Ohmoc
.-with:is:model:
.
+ (instancetype) get:(NSString*)id
Convenience method for Ohmoc
.-get:
.
+ (instancetype) create
Convenience method for Ohmoc
.-createModel:
.
+ (instancetype) create:(NSDictionary*)properties
Convenience method for Ohmoc
.-create:model:
.
+ (OOCSet*) all
Convenience method for Ohmoc
.-allModels:
.
+ (OOCCollection) collectionWithProperty:(NSString)propertyName scoreBetween:(double)min and:(double)max andProperty:(NSString)filterProperty is:(id)groupByValue range:(NSRange)range reverse:(BOOL)reverse ohmoc:(Ohmoc)ohmoc
Gets a collection of objects whose propertyName
is between min
and max
.
Optionally, if filterProperty
is provided, it will only returns the objects with a value groupByValue
for it.
A range
may determine a maximum number of elements and an offset.
If reverse
is true, the elements will be in decreasing order.
ohmoc
is optional. If not provided, the default instance will be used.
+ (OOCCollection) collectionWithProperty:(NSString)propertyName scoreBetween:(double)min and:(double)max andProperty:(NSString*)filterProperty is:(id)groupByValue range:(NSRange)range
Calls +collectionWithProperty:scoreBetween:and:andProperty:is:range:reverse:ohmoc:
using false as reverse parameter and the default Ohmoc instance.
+ (OOCCollection) collectionWithProperty:(NSString)property scoreBetween:(double)min and:(double)max range:(NSRange)range reverse:(BOOL)reverse ohmoc:(Ohmoc*)ohmoc
Calls +collectionWithProperty:scoreBetween:and:andProperty:is:range:reverse:ohmoc:
with no property filter.
+ (OOCCollection) collectionWithProperty:(NSString)property scoreBetween:(double)min and:(double)max range:(NSRange)range reverse:(BOOL)reverse
Calls +collectionWithProperty:scoreBetween:and:andProperty:is:range:reverse:ohmoc:
with no property filter and the default Ohmoc instance.
+ (OOCCollection) collectionWithProperty:(NSString)property scoreBetween:(double)min and:(double)max range:(NSRange)range
Calls +collectionWithProperty:scoreBetween:and:andProperty:is:range:reverse:ohmoc:
with no property filter, the default Ohmoc instance, and false as reverse.
+ (OOCCollection) collectionWithProperty:(NSString)property scoreBetween:(double)min and:(double)max
Calls +collectionWithProperty:scoreBetween:and:andProperty:is:range:reverse:ohmoc:
with no property filter, the default Ohmoc instance, false as reverse and no range limit.
+ (OOCCollection) collectionWithProperty:(NSString)property scoreBetween:(double)min and:(double)max ohmoc:(Ohmoc*)ohmoc
Calls +collectionWithProperty:scoreBetween:and:andProperty:is:range:reverse:ohmoc:
with no property filter, false as reverse and no range limit.
- (void) applyDictionary:(NSDictionary*)properties
Applies all properties
into the current object. The keys of the NSDictionary
are mapped to property names and the value converted to the property declared type if possible.
- (OOCModel) initWithId:(NSString)id ohmoc:(Ohmoc*)ohmoc
Initializes the model with a specific id and Ohmoc
instance. If the id
already exists, load
must be called.
- (instancetype) initWithDictionary:(NSDictionary)properties ohmoc:(Ohmoc)ohmoc
Initializes the object with an Ohmoc
instance and applies the properties
.
- (id) get:(NSString*)prop
Refreshes the property prop
from the database and return its value. Notice the value returned is an Objective-C class, which means that c types are wrapped around a container. For example, int
return instances of NSNumber
.
- (void) set:(NSString*)att value:(id)val
Synchronously writes only the value val
into the model att
in the database. This method does not update indices, so it must only be used for non-indexed properties.
- (void) save
Writes all properties of the model into the database and updates all indices.
- (void) load
Gets all the model properties from the database. The model must have an id
.
- (void) delete
Remove the object from the database and removes all of its indices.
Updated less than a minute ago