Wednesday, October 1st, 2008

JStORM: A New JavaScript Object-Relational Mapper

Category: Database, JavaScript

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.
* 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:


  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. });
  10. Person.all().each(function(person) {
  11.   console.log(person.firstName);
  12. });

Looking forward to seeing some docs, Uriel ;-)

Posted by Ben Galbraith at 7:29 am

3.4 rating from 27 votes


Comments feed TrackBack URI

Yeha,docs are coming in,also i am going to write some wiki pages to explain how to implement providers since many people are interested in this.

Comment by Urielka — October 1, 2008

Interesting and probably great work, though I still don’t understand why so few understand that moving from n’tier to n*n’tier is a bad thing … ;)
I am not against Ajax, though I am for server-side binded Ajax libraries)

Comment by ThomasHansen — October 1, 2008

Hello, I just signal a similar project (syntax a little shorter) :

Comment by morphine — October 1, 2008

Of all types of ORM products, I liked db4o the best for its simplicity. It is a Java-based product, but I am siting it as an example for its simple syntax and usage.

Most ORM products are too intrusive or want us to learn new syntaxes, so they are not easily replaceable.


PS: I don’t work for db4o, nor have any other interest in db4o.

Comment by ragjunk — October 1, 2008

db4o is first of all also a product for .Net and Mono, second of all (and more importantly) it is not an ORM tool but an OO database which is quite a difference … ;)
I don’t work for them either BTW…

Comment by ThomasHansen — October 1, 2008

Just wanted to mention our newish library JazzRecord ( in case anyone was interested in a JavaScript ActiveRecord clone in specific.

I find the syntax to be more concise than Morphine or JStORM, though JStORM seems somewhat similar in terms of usage.

Jazz is built on MooTools, and requires the inclusion of the base library to work.

Comment by thynctank — November 11, 2008


Some of these libraries don’t deal with server databases at all (JazzRecord being one of them). Instead, they are being built for use as value add-ons for caching web apps using Gears/similar technology, or, perhaps more importantly, as facilitators for clean database code in desktop JavaScript platforms like Adobe AIR.

Comment by thynctank — November 11, 2008

Leave a comment

You must be logged in to post a comment.