框架的JavaScript客户端ORM?

最近我使用JSON / Rest服务,并在服务器上手动input对数据库进行基本CRUD操作的方法。

我想要做的,是在JavaScript(基于Ajax的应用程序)做一些forms

var allStudents = students.getAllStudents(); // returns all items of the students table var student = new student(); student.name = "Joe"; student.address = "123 Sesame st"; students.add(student); // commits it to the students table var student = students.getStudentById(57); 

现在和任何ORM一样,所有这些方法都会自动/为我写。

另外请注意,我不是说Javascript应该直接与数据库交谈。 它仍然会进行Restful调用(幕后到服务器)。 但我只是希望这些crud操作对我来说是自动化和透明的,这样我就不需要手动在服务器上写出这些操作。

你们知道任何有助于实现这个目标的框架吗?

我的主要后端是Java / Spring3MVC。 但是我也想听听使用Node.js的想法。

我不确定这是否节省时间,而不是简单地编写RESTful Ajax请求,但Dojo的JsonRest商店是我见过的一个解决scheme,它与您所描述的类似。 就我个人而言,我发现明确地写ajax请求更具可读性,但是如果您不介意遵循Dojo的哲学,就如何构build请求,您可能会喜欢这样。 无论如何,下面是该文档页面的一些代码:

 require(["dojo/store/JsonRest"], function(JsonRestStore){ var store = new JsonRestStore({target: "/Table/" }); store.get(3).then(function(object){ // use the object with the identity of 3 }); store.query("foo=bar").then(function(results){ // use the query results returned from the server }); store.put({ foo: "bar" }, { id: 3 }); // store the object with the given identity store.remove(3); // delete the object }); 

如果您可以使用像Backbone.js或Can.js(推荐)的方式来执行您的界面,并通过RESTfull服务与您的数据库无缝沟通,那么您将会留下深刻的印象,如果您之前没有看到过。

http://backbonejs.org/ http://canjs.us/

两者都使用一个非常容易设置的MVC结构。 看看演示和例子。

寻找同样的东西,我偶然发现了sproutcorelogging 。 看起来像一个JavaScript orm解决scheme。