JazzRecord is about making databases fun. It's about removing all of the garbage and discontinuity of API and data format in Gears and Adobe AIR.
To actually do much of anything with JazzRecord, you'll need to do the following:
- Setup an adapter for your given runtime environment.
- Setup data models
- (optional) Associate them to one another
- (optional) Provide models with validations to prevent dirty data from infiltrating the database.
- (optional) Provide models with behavior and callbacks which can then affect your application.
- Use automigration OR Setup migrations
After you've prepped your database, you can go to town:
- Query models for record objects.
- Custom finders and other methods provided in the model definition will be made available to the model.
- Record objects can be modified and saved back down to update the database.
- Record objects can be destroyed, deleting the corresponding rows in the database.
- Record objects automatically have access to associated data stored in the database when they are first instantiated.
- Associated data is loaded into sub-objects accessed as properties of the primary record object. This is as expected if you've worked much with ActiveRecord.
- Any custom methods provided in the model definition will be made available to record objects returned by the model.
- Any validations or callbacks provided in the model definition will be called automatically on save, on update, or during specified actions.
While we'd like to think JazzRecord is all but difficult to use, there are of course caveats.
In order to fully appreciate JazzRecord, you'll want a console to debug with, view log statements with, and possibly grow old with. For that, of course, we recommend the amazing Firebug and Firebug Lite in browsers, although Safari/Webkit/Chrome have built in consoles that aren't too shabby. In Adobe AIR, we recommend running AIRIntrospector.
Limitations of JazzRecord
For the most part, JazzRecord follows ActiveRecord concepts once its data and models are in place. Qeurying models and working with records is mostly the same. However, keep a few things in mind:
- Currently, there is no formal migration syntax. This is under development but not yet ready for prime time.
- Model definition and table definition usually happen in the same place, and are the basis for "automigration", which allows Jazz to build model tables and mapping tables based on model declarations provided prior to a call to the function
- JazzRecord only loads 1 level of associations by default. This can be overridden as a config option in your code, or overridden per each call to one of the finder methods.
- Association data beyond the pre-loaded depth is easily retrievable by calling the
load()method of the primary record object.
- JazzRecord does not handle any of the more complicated ActiveRecord magic, like "has many through", or polymorphism (STI or inherited models) as of yet.