Tuesday, October 9, 2007

AIR Local Database Helper Class

This is a quick little app that showcases a class I created (LocalDatabaseService.as) to take some of the boilerplate code out of dealing with the local database in AIR. You can create an ActionScript object and pass it into the createTable method and it will create the table for you by interrogating the AS object. You can then use the add, update, save, remove, getAll, and getByID methods by passing in an object along with the table name and a responder. There is still a lot I would like to do with this, and there is definitely some refactoring to be done, but I wanted to share just the same.

Requirement: Your ActionScript object must have an id property named "ID".

Next up, I am going to add some code to handle one-to-many and many-to-many relationships between objects. Maybe create some recursive saving and add a little documentation... but not tonight. :)

Enjoy...

Sample Application: IdeaBank

3 comments:

TJ Downes said...

Nice work!

Unknown said...

Nice mate, Might want to check out ActiveRecord ideas from Ruby on Rails etc... :)

Pat Smitherman said...

Thanks guys! Yeah, I've worked with Rails and several ORM frameworks and that is what prompted this in the first place. If I can find the time I would love to flesh this out into a full Data Mapper.