javascript客户端ORM的框架?

javascript客户端ORM的框架?,javascript,node.js,Javascript,Node.js,我有点厌倦了最近使用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 = "1

我有点厌倦了最近使用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可能。

如果您可以使用类似Backbone.js或can.js(推荐)的东西来实现接口,并通过RESTfull服务与数据库无缝通信,如果您以前没有见过,您会对这种方式印象深刻

http://canjs.us/

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

与简单地编写RESTful ajax请求相比,我还不确定这是否节省时间,但Dojo是我见过的一种解决方案,其工作原理与您描述的类似。就个人而言,我觉得显式编写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

});

寻找同样的东西,我偶然发现。看起来像一个javascript orm解决方案。

在我看来像是一个巨大的安全漏洞。这与运行诸如“yourserver/addStudent/name/joe/address/sesamest”之类的RESTful方法有什么区别。。。服务器仍在进行提交。同样的安全是的,在某种程度上。如果要使用此体系结构,则需要一些可插入的安全模型,强制您批准/拒绝所有提交。没有这一点,这确实是一个安全漏洞。无意冒犯,但你读过我的问题吗?主干/CANJ不会远程执行我要求的操作。MVC不是我所要求的。