Bene bene é arrivato anche un nuovo ORM Javascript per Gears…saranno molto contenti Hibernate e Propel.
Ecco alcuni esempi presi da JStORM
var Person = new JStORM.Model({
name:"Person",
fields:
{
firstName:new JStORM.Field({type:"String",maxLength:25}),
lastName:new JStORM.Field({type:"String",maxLength:25}),
},
connection:"default"
});
For example to print all the persons in the database:
Person.all().each(function(person)
{
console.log(person.firstName);
});
What the all function do is to create a new instance of JStORM.Query for Person model.
Other function that return a query is filter,filter return a query filtered by a criteria,for example:
var katzFamily = Person.filter("lastName = ?","Katz");
katzFamily.each(function(person)
{
console.log(person.firstName);
});