News, Commentary and Insights from the Flash Player and AIR Product and Engineering Teams

ActiveRecord JavaScript Library Announced AIR Support

Ryan Johnson of Aptana announced the beta version of ActiveRecord.js, an open source JavaScript library that implements the ActiveRecord pattern popularized by the Ruby on Rails community. In addition to supporting Adobe AIR, it provides support for other JavaScript application runtimes including web browsers. On the server-side, ActiveRecord.js also works with MySQL and SQLite via Aptana Jaxer, the Ajax server based on the Mozilla browser engine. Work is underway as well to support HTML 5’s SQL APIs, now available in some versions of WebKit, once that specification is finalized.

For developers creating Ajax applications using Adobe AIR, this means they can persist JavaScript objects and data using pure JavaScript syntax. All the underlying SQL commands are simplified into higher level APIs that are more natural feeling for JavaScript developers. In many cases, the syntax results in far fewer lines of code to implement as well.

There is an Adobe AIR sample application provided with the project that demonstrates a basic example of the ease of use.

As shown below, it takes one line to connect ActiveRecord.js and a few lines more to define a record object, in this case Note.

Perhaps the most verbose part of the sample is where it directly updates the user interface using native HTML DOM APIs. Of course, this could be further simplified by using jQuery, Dojo Toolkit, Ext JS and other popular Ajax libraries. ActiveRecord.js is intended to complement, not replace, the use of other Ajax libraries.