JStORM: A New JavaScript Object-Relational Mapper

View original post found on Ajaxian » Front Page authored by Ben Galbraith

Uriel Katz wrote in to tell us that he’s burned his GearsORM framework to the ground to create the entirely new JStORM framework, announced in his blog. JStORM currently supports Google Gears, Aptana Jaxer, and Adobe AIR, but it’s still bleeding edge: no documentation yet, just code. But the feature-set is interesting:

* define your tables as models.
* full CRUD support.
* events on(Before/After)Delete/Save/Update.
* SQL LIMIT/OFFSET support.
* order by support.
* automatic creation of tables.
* selecting and deleting over relations.
* easy iterating with each syntax like in Ruby,support for query chaining and more.
* basic introspection support.
* transaction support.
* self relations.
* support multiple backends and multiple dialects,currently MySQL (in Jaxer only) and Sqlite (Jaxer, Gears and AIR).

Here’s an example of loading “Person” entities from a database using JStORM:

PLAIN TEXT
JAVASCRIPT:

  1. var Person = new JStORM.Model({
  2.   name:“Person”,
  3.   fields: {
  4.      firstName:new JStORM.Field({type:“String”,maxLength:25}),
  5.      lastName:new JStORM.Field({type:“String”,maxLength:25}),
  6.   },
  7.   connection:“default”
  8. });
  9.  
  10. Person.all().each(function(person) {
  11.   console.log(person.firstName);
  12. });

Looking forward to seeing some docs, Uriel ;-)

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment