用于javascript客户端ORM的框架?

我最近厌倦了使用
JSON / Rest服务并在服务器上手动键入对数据库执行基本CRUD操作的方法.

我想做的是,在javascript(基于ajax的应用程序)中做一些表单

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 store是我见过的解决方案与您所描述的类似的解决方案.就个人而言,我发现明确地编写ajax请求更具可读性,但如果你不介意遵守Dojo关于如何构建请求的理念,你可能会喜欢这样.无论如何,这里是该文档页面的一些代码:

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

});
点赞